Question

I have a toolstrip container with two toolstrips. I want to force one of them to be displayed on top of the other. I tried setting Dock to Top for one and to Bottom for the other, but they are still displayed randomly. I also tried using TopToolStripPanel.Controls.SetChildIndex(...) but it didn't have an effect. Even the same executable on two different pc's gives different order. Is there a way to force the order? Thanks

Was it helpful?

Solution

Add these lines of code after InitializeComponent(); to your form's constructor to ensure your specific order. This fixes any messed up settings in the designer generated code:

toolStripContainer1.TopToolStripPanel.SuspendLayout();
toolStrip1.Dock = DockStyle.None;
toolStrip2.Dock = DockStyle.None;
toolStrip1.Location = new Point(0, 0);
toolStrip2.Location = new Point(0, toolStrip1.Height);
toolStripContainer1.TopToolStripPanel.ResumeLayout();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top