Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reorder ToolStrip items in code

Tags:

c#

How do you programatically reorder items on a ToolStrip in C#.

Thanks.

like image 936
HAdes Avatar asked Nov 11 '08 16:11

HAdes


People also ask

How do I add a toolstripdropdownbutton?

Dim ts As New ToolStrip() ' Create a ToolStripDropDownButton control and add it ' to the ToolStrip control's Items collections.

How do I dynamically populate the menu item collection of Toolstrip?

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.

How to set the value of a form's toolstripmenuitem?

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).

How do I add an item to a collection?

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.


1 Answers

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);
like image 149
HAdes Avatar answered Sep 20 '22 11:09

HAdes