What is the difference between Dock and Anchor

37,980

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.

Share:
37,980
Sarath Subramanian
Author by

Sarath Subramanian

Updated on December 03, 2020

Comments

  • Sarath Subramanian
    Sarath Subramanian over 3 years

    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 the form's size gets changed. I need to know the difference between Dock and Anchor to implement this. What is the actual difference between Docking and Anchoring?