Problem with order of Dock->Top controls

You have to organize the order of your controls in the Document Outline window (VIEW -> Other Windows -> Document Outline (Ctrl+W, U)). Select your form in Desing Mode and you will see all your components in a tree view. Use the arrows on the top to select the desired order.

It is better than cut and past because it will avoid loss of binding callbacks.


Right click on the Controls and select "Send to Back" or "Bring to Front", or use the Document Outline Window to rearrange the Z-Order of the items. Document Outline helps a lot when creating WinForms things with lots of controls.


The dock layout is based on the order they are added to the container.

I usually go to the *.Designer.cs file and modify the InitializeComponent() method to manually re-order how the controls are added to the container.

this.Controls.Add(this.panel1);
this.Controls.Add(this.panel4);
this.Controls.Add(this.panel3);
this.Controls.Add(this.panel2);

This order is opposite on display


It depends on the order you have added those controls to their container. The earlier added control will be the topper one and so on ...

To fix it, "Cut" the forth control and "Paste" it again to the container and it will take the desirable place.

Another way to fix it is by modifying the designer file code to re-order the adding of those controls to their container.

Tags:

C#

Winforms