What is the difference between Dock and Anchor

前端 未结 1 1973
攒了一身酷
攒了一身酷 2020-12-16 11:06

I have a windows form which have a lot of controls in that(Listbox,Groupbox,Combobox,TextBox,ListBox etc). I need to resize and arrange the controls automatically whenever t

相关标签:
1条回答
  • 2020-12-16 11:42

    The Anchor and Dock properties of a form are two separate properties.

    Anchor refers to the position a control has relative to the edges of the form. A textbox, for example, that is anchored to the left edge of a form will stay in the same position as the form is resized.

    Docking refers to how much space you want the control to take up on the form. If you dock a control to the left of the form, it will stretch itself to the height of the form, but its width will stay the same.

    This EXAMPLE can help you understand a bit more.

    0 讨论(0)
提交回复
热议问题