How can I organize controls on a form relative to each other and the form itself?

I have a child form in an MDI Windows Forms application. It has two controls: ComboBox and TreeView, and the last under the first. Both controls are the same width. How can I customize them and form properties to achieve the following:

  • When resizing a form, the width of both controls must be equal to the width of the form.
  • The height of the TreeView must change to fill all the free space of the form.
+3
source share
3 answers

You can do the following:

  • In the form designer, create controls as you want them to look.
  • ComboBox Anchor ,
  • TreeView Anchor Top, Left, Right Bottom
+5

, . Dock , "", .

, Combobox Dock=Top TreeView Dock=Fill:

enter image description here

, TreeView , .

+3

Anchor. (combobox, treeview usercontrol), , .

The property is Docksimilar, but it also affects the location and kind of “sticks” the control into place even in the form designer.

+1
source

Source: https://habr.com/ru/post/1796264/


All Articles