C # WinForm controls to adjust the order of the Dock

  

C # WinForm controls to adjust the order of the Dock

Recently .net winform out of control layout confused, because the controls are using the Dock mode, the operation is relatively easy, if maximized, window resizing, etc., can vary with the size of the window.
But the question is, .net winform the dock embodiment is arranged according to the priority control sequence Dock added first, I think there are three assumptions controls A, B, C respectively, Top, Bottom, and Fill manner of filling the opening window looks i.e. It should look like this:

---------------------

A

---------------------

C

---------------------

B

----------------------

 

The question is, now I want to add D controls and how to do in the middle of A C? Try a lot of ways will not work, usually overwrite C control, the control is added last.

Find the Internet, many people have no choice but to propose a solution, that is to start over, to add controls to the window again in form, although you can solve the problems caused by Dock layout, but at the same time bring the doubled workload difficult to adjust to exactly the same with the previous layout.

 

Presumably this is not the solution, add add, I always wanted to add the controls to have the right to prioritize the Dock, should be able to proceed from the Designer file ah.

 

 Locate the following code:

this.Controls.Add(this.D); 

this.Controls.Add(this.C);
this.Controls.Add(this.B);
this.Controls.Add(this.A);

 

 The code sequence is adjusted to:

 

this.Controls.Add(this.C); 
this.Controls.Add(this.D);
this.Controls.Add(this.B);
this.Controls.Add(this.A);

 

That solved the problem.

 Thus, in Desinger file is later added to the high priority control Dock sorted, i.e. the highest priority A sort control (following control high priority).

Guess you like

Origin www.cnblogs.com/Angel-szl/p/11505829.html