caesay caesay - 3 months ago 18
C# Question

How to control docking order in WinForms

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 i cant seem to find what the

RightClick->Order->SendToFront
is doing, because thats exactly what I want to happen. As far as I can get to happen, as I add my contents to my control, the newest contents is always at the top, and I'd like for the Newer contents to be on the bottom, and the oldest contents to be at the top.

Summary: Is there an easy way in WinForms (C#), to control the order in which things dock to the sides of controls?

Edit: I have to do this from the code behind as i add my controls, I can't use any features of the WinForm's designer, but what I am trying to do, is mimic the WinForms Designer
SendToBack
and
SendToFront
features

Answer

Use these methods:

myControl.SendToBack();
myControl.BringToFront();
Comments