Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to control docking order in WinForms

I'm looking for a way to control the order in which the items dock to the top of my control.

I've noticed as I add children to my control (in the designer, or through code), the newest child is always at the top. I'd like for the newer children to be on the bottom, and the oldest to be at the top.

Is there a way to do this through code? In the WinForms designer, RightClick->Order->BringToFront / SendToBack is doing something similar to what I want to do, but how can this be done programmatically?

like image 212
caesay Avatar asked Apr 09 '10 12:04

caesay


People also ask

What is meaning of docking of controls in WinForms?

Docking refers to how much space you want the control to take up on the form. If you dock a control to the left of the form, it will stretch itself to the height of the form, but its width will stay the same.

How do you place control on a form?

To place controls on your form, you select them in the Toolbox and then draw, on the form, the rectangle in which the control will be enclosed. Or you can double-click the control's icon to place an instance of the control on the form.


2 Answers

Go to View → Other windows → document outline.

In that window drag the controls so the docking is as you like it to be.

like image 153
Stormenet Avatar answered Oct 13 '22 06:10

Stormenet


Use these methods:

myControl.SendToBack(); myControl.BringToFront(); 
like image 43
serhio Avatar answered Oct 13 '22 06:10

serhio