Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Dock and Anchor

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?

like image 575
Sarath KS Avatar asked Oct 27 '14 05:10

Sarath KS


People also ask

What is dock in Windows form?

Remarks. Use the Dock property to define how a control is automatically resized as its parent control is resized. For example, setting Dock to DockStyle. Left causes the control to align itself with the left edges of its parent control and to resize as the parent control is resized.

What is the difference between anchored and moored?

Mooring refers to lassoing, tethering, tying, or otherwise securing your boat to a fixed object, such as a mooring buoy, rather than dropping an anchor to secure your vessel anywhere you fancy. You can moor your boat to a mooring buoy, dock, quay, wharf, jetty, or pier.

How do I dock in Visual Studio?

Use the Visual Studio designer Properties window to set the docking mode of a control. Select the control in the designer. In the Properties window, select the arrow to the right of the Dock property. Select the button that represents the edge of the container where you want to dock the control.


1 Answers

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.

like image 176
Nadeem_MK Avatar answered Oct 08 '22 13:10

Nadeem_MK