6

Which property of ToolStripButton is responsible for their position order on a ToolStrip?
I need that property so that I can dynamically change positions of ToolStripButtons on a ToolStrip.

Danny Beckett
  • 20,529
  • 24
  • 107
  • 134

1 Answers1

5

There isn't a property for this. The buttons are contained in a ToolStripItemCollection which holds the general ToolStripItem instances. You can behave with it like a C# collection. Like other collections, you can clear it, add or insert items at any arbitrary position, etc. Like:

toolStrip1.Items.Clear();

toolStrip1.Items.Add(toolStripButton3);
toolStrip1.Items.Add(toolStripButton2);
toolStrip1.Items.Add(toolStripButton1);

toolStrip1.Items.Insert(toolStripButton4, 2);

To convert the ToolStripItemCollection to a C# collection with more capabilities (like Sort and Reverse) convert it to an ArrayList:

System.Collections.ArrayList list = new System.Collections.ArrayList(toolStrip1.Items);

This question might be interesting to you too.

Community
  • 1
  • 1
Hossein
  • 4,097
  • 2
  • 24
  • 46
  • Thanks, I think using this I can change button positions dynamically, if am successful will post answer here –  Apr 30 '13 at 12:29
  • 2
    Don't understand why is my question closed. What I need is to dynamically change positions of buttons on toolstrip. I don't think this question is vague. I need this in my project. –  May 01 '13 at 09:38
  • 2
    Its closed because some people have nothing better to do than to carry on like childish bullies. The question makes perfect sense to me. – Peter Jamsmenson Sep 15 '16 at 10:06