Question
Im currently adding toolstrips from my seperate modules like:
this.toolStripContainer.TopToolStripPanel.Controls.Add(module.Instance.Toolbar)
Buy they are then in the order that the modules are loaded which isnt very good. Is there any way to re-order them?
Or should I be looking at adding some sort of index to my modules and laoding them in the order that I want the toolstrips?
Solution 2
I ended up adding all the toolstrips to a list... sorting the list by ToolStrip.Tag... and then adding them to the control list...
This allows the module writer to set a priority for the toolstrip, kind of like toolstrip merging
OTHER TIPS
The Controls collection has a SetChildIndex(Control child, int newIndex) method. See if you can use that method to order the controls as per your need.
EDIT: Just did a quick test. You need to call SuspendLayout() before adding the controls and then ResumeLayout() once you're done:
this.toolStripContainer1.TopToolStripPanel.SuspendLayout();
this.toolStripContainer1.TopToolStripPanel.Controls.Add(t1);
this.toolStripContainer1.TopToolStripPanel.Controls.Add(t2);
this.toolStripContainer1.TopToolStripPanel.Controls.SetChildIndex(t1, 1);
this.toolStripContainer1.TopToolStripPanel.ResumeLayout();
I solved like this:
StripContainer.TopToolStripPanel.Join(
Instance.MMethod.Main.ToolStripMenu,
StripContainer.TopToolStripPanel.Controls[
StripContainer.TopToolStripPanel.Controls.Count - 1].Right,
0);