Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Toolstrip order in Toolstrip container

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

like image 395
Jerry Avatar asked Nov 01 '22 13:11

Jerry


1 Answers

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();
like image 193
Andreas Adler Avatar answered Nov 15 '22 06:11

Andreas Adler