Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with order of Dock->Top controls

Tags:

c#

winforms

C# WinForms: I am designing my form and I have a couple of TableLauots. so I design my first tablelayout, throw it on the panel and set Dock->Top ... then I design my second one and do the same and set Dock->Top, it goes to Top again and good, it places under the previous one that was on top...I design the third one and set its dock.top and good it is under second one which is under first one...but I dunno what is the diffrence for the forth one that when I set its dock.top, it changes the order of the other three ones and get places some where in between them, it does not get placed under the third one...any idea what should I look in to?

like image 767
Bohn Avatar asked Jun 24 '11 21:06

Bohn


People also ask

How do I Dock controls in Windows Forms?

Select the control in the designer. In the Properties window, select the arrow to the right of the Dock property. Select the button that represents the edge of the container where you want to dock the control. To fill the contents of the control's form or container control, press the center box.

What is docking and anchoring controls?

Anchor refers to the position a control has relative to the edges of the form. A textbox, for example, that is anchored to the left edge of a form will stay in the same position as the form is resized. Docking refers to how much space you want the control to take up on the form.

Which control you would select to place the child controls in top left right and bottom using Dock property?

The TableLayoutPanel control supports the Anchor and Dock properties in its child controls.

What is docking a control?

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.


2 Answers

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.

like image 68
Akram Shahda Avatar answered Sep 20 '22 12:09

Akram Shahda


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.

like image 29
DaveShaw Avatar answered Sep 20 '22 12:09

DaveShaw