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
.
Asked
Active
Viewed 3,589 times
6

Danny Beckett
- 20,529
- 24
- 107
- 134
-
3+1. Good question. Don't know why people downvoted this. – Hossein Apr 30 '13 at 11:03
-
Maybe they think this question doesn't deserve to be answered :( – Apr 30 '13 at 11:05
-
Thanks for input, i did the same now – Apr 30 '13 at 11:07
1 Answers
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.
-
Thanks, I think using this I can change button positions dynamically, if am successful will post answer here – Apr 30 '13 at 12:29
-
2Don'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
-
2Its 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