How do you programatically reorder items on a ToolStrip in C#.
Thanks.
Dim ts As New ToolStrip() ' Create a ToolStripDropDownButton control and add it ' to the ToolStrip control's Items collections.
You can dynamically populate the menu item collection of a ToolStripcontrol when the menu opens. Example The following code example demonstrates how to dynamically add items to a ContextMenuStripcontrol. The example also shows how to reuse the same ContextMenuStripfor three different controls on the form.
Set a property in your Form on which you have added ToolStripMenuItem. Create a method to pass value to the above property. You need to check for all open forms and then access the form object where we have created the property (where we have the ToolStripMenuItem).
You probably used the Add method that appends the item to the collection, instead use the Insert method where you can specify the index where you want the item inserted. DIY: Before posting, try to debug your code, try to search documentation/web for information/solutions.
I have found a way around this by using the Insert() method of the Items collection and specifying the index i want the item at.
i.e.
toolStrip1.Items.Insert(0, myButton);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With