How to: Align a Control to the Edges of Forms at Design Time

 

You can make your control align to the edge of your forms by setting the Dock. This property designates where your control resides in the form. The Dock property can be set to the following values:

SettingEffect on your control
BottomDocks to the bottom of the form.
FillFills all remaining space in the form.
LeftDocks to the left side of the form.
NoneDoes not dock anywhere, and it appears at the location specified by its Location.
RightDocks to the right side of the form.
TopDocks to the top of the form.

These values can also be set in code. For more information, see How to: Align a Control to the Edges of Forms.

System_CAPS_ICON_note.jpg Note

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Customizing Development Settings in Visual Studio.

To set the Dock property for your control at design time

  1. In the Windows Forms Designer, select your control.

  2. In the Properties window, click the drop-down box next to the Dock property.

    A graphical interface representing the six possible Dock settings is displayed.

  3. Choose the appropriate setting.

  4. Your control will now dock in the manner specified by the setting.

Control.Dock
Control.Anchor
How to: Align a Control to the Edges of Forms
Walkthrough: Arranging Controls on Windows Forms Using Snaplines
How to: Anchor Controls on Windows Forms
How to: Anchor and Dock Child Controls in a TableLayoutPanel Control
How to: Anchor and Dock Child Controls in a FlowLayoutPanel Control
Walkthrough: Arranging Controls on Windows Forms Using a TableLayoutPanel
Walkthrough: Arranging Controls on Windows Forms Using a FlowLayoutPanel
Developing Windows Forms Controls at Design Time

Show: