As the title states, I\'m looking for a way to control the order in which the items dock to the top of my control.
I\'ve played with the windows form designer, and
The order in which the controls are being added to the Controls collection determines the docking order.
(For the sake matter of showing another option): In Visual Studio 2012 (and later):
This will give you the possibility to rearrange the Controls to your desired order.
Go to View → Other windows → document outline.
In that window drag the controls so the docking is as you like it to be.
Note that when doing this programmatically, then there's a very easy way to achieve this, namely:
containerPanel.Controls.SetChildIndex(Element, 0); //sends element to the bottom of the list
As you said, the newest control added to the controls collection is the one on top. If you need a newer control to be added at the bottom, I'll suggest to create a list of controls, add the controls to the list, reverse the list and add the list to the controls collection.
List<Control> controls = new List<Control();
controls.Add(new myFirstControl());
controls.Add(new mySecondControl());
controls.Reverse();
this.Controls.AddRange(controls.ToArray());
Use these methods:
myControl.SendToBack();
myControl.BringToFront();