How to dock a child control to bottom right of the parent control?

Nick picture Nick · May 24, 2012 · Viewed 16.4k times · Source

How do i dock a child control at a bottom right position when compared to the parent control?

I can see that the dockstyle enum has values for None,Top,Bottom,Right,Left and Fill ...

How can i set for Bottom right ???

Answer

JotaBe picture JotaBe · May 24, 2012

perhaps you don't want to dock it bottom-right. Docking changes the position of the control, but also the size to fit in th height or width of the form.

If you want to keep it down and on the right, anchor it.Remove left and top anchors and add bottom and right anchors. Your control will keep there!

** EDIT ** According to OP comment, it must be on the bottom and take all width and have fixed height. then you must take this steps:

To keep it tidy, you need at least 2 controls:

  • The one that it's on the bottom: dock it to the bottom and set its height.
  • Other one that use docking style of Fill. This makes it take all the space not occupied by the bottom control.

If you have problems setting it up, use the Layout Window (I hope that's the name in English. My VS is localized) to move them around until it works. Sometimes docking it's a bit nasty and the only way to make it work the way you like is changing the order nad nesting of controls using this layout window.