P.Brian.Mackey
P.Brian.Mackey

Reputation: 44275

Control Dock.Top order without InitializeComponent()

We are not supposed to modify the contents of InitializeComponent(). Yet, the order that the designer adds our controls determines the stack order of Docking. For example, the designer might generate:

private void InitializeComponent()
{
            //...
            this.Controls.Add(this.dockTop); 
            this.Controls.Add(this.dockTop2);

Where dockTop and dockTop2 are of type Panel with Dock = DockStyle.Top. This results in dockTop2 at the top of the Form. If I want dockTop2 at the top of the form, then I have to modify the designer file (which we are not supposed to do as the changes can be over-written).

So, how can I set the order of my docking?

Upvotes: 1

Views: 300

Answers (2)

Hans Passant
Hans Passant

Reputation: 941317

The order isn't set by the designer, it is set by you. Initially by the order in which you add controls. You can alter the order by right-clicking a control and choosing Bring to Front or Send to Back. Get fine-grained control over the order with View + Other Windows + Document Outline. You can drag+drop a control in the list to move it.

Upvotes: 4

hawbsl
hawbsl

Reputation: 16003

The standard way to manipulate a form containing several docked controls, as I understand it, is to Cut the panels, groupboxes, whatever and Paste them back in in order of precedence.

Upvotes: 0

Related Questions