Export (0) Print
Expand All

How to: Align a Control to the Edges of Forms

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

Setting

Effect on your control

Bottom

Docks to the bottom of the form.

Fill

Fills all remaining space in the form.

Left

Docks to the left side of the form.

None

Does not dock anywhere, and it appears at the location specified by its Location property.

Right

Docks to the right side of the form.

Top

Docks to the top of the form.

There is design-time support for this feature in Visual Studio.

TopicLocation
How to: Create a Windows Forms Control That Takes Advantage of Design-Time Features.NET Framework: Application Development
How to: Create a Windows Forms Control That Takes Advantage of Design-Time Features.NET Framework: Application Development
How to: Display a Control in the Customize Toolbox Dialog BoxWindows Forms Controls
Walkthrough: Serializing Collections of Standard Types with the DesignerSerializationVisibilityAttributeWindows Forms Controls
Walkthrough: Inheriting from a Windows Forms Control with Visual C#Windows Forms Controls
How to: Provide a Toolbox Bitmap for a ControlWindows Forms Controls
How to: Inherit from Existing Windows Forms ControlsWindows Forms Controls
Walkthrough: Debugging Custom Windows Forms Controls at Design TimeWindows Forms Controls
How to: Inherit from the Control ClassWindows Forms Controls
How to: Test the Run-Time Behavior of a UserControlWindows Forms Controls
How to: Align a Control to the Edges of Forms at Design TimeWindows Forms Controls
How to: Inherit from the UserControl ClassWindows Forms Controls
How to: Author Controls for Windows FormsWindows Forms Controls
How to: Author Composite ControlsWindows Forms Controls
Walkthrough: Authoring a Composite Control with Visual BasicWindows Forms Controls
Walkthrough: Authoring a Composite Control with Visual C#Windows Forms Controls
Walkthrough: Inheriting from a Windows Forms Control with Visual BasicWindows Forms Controls
How to: Display a Control in the Customize Toolbox Dialog BoxWindows Forms Controls
Walkthrough: Serializing Collections of Standard Types with the DesignerSerializationVisibilityAttributeWindows Forms Controls
Walkthrough: Inheriting from a Windows Forms Control with Visual C#Windows Forms Controls
How to: Provide a Toolbox Bitmap for a ControlWindows Forms Controls
How to: Inherit from Existing Windows Forms ControlsWindows Forms Controls
Walkthrough: Debugging Custom Windows Forms Controls at Design TimeWindows Forms Controls
How to: Inherit from the Control ClassWindows Forms Controls
How to: Test the Run-Time Behavior of a UserControlWindows Forms Controls
How to: Align a Control to the Edges of Forms at Design TimeWindows Forms Controls
How to: Inherit from the UserControl ClassWindows Forms Controls
How to: Author Controls for Windows FormsWindows Forms Controls
How to: Author Composite ControlsWindows Forms Controls
Walkthrough: Authoring a Composite Control with Visual BasicWindows Forms Controls
Walkthrough: Authoring a Composite Control with Visual C#Windows Forms Controls
Walkthrough: Inheriting from a Windows Forms Control with Visual BasicWindows Forms Controls
How to: Create a Windows Forms Control That Takes Advantage of Design-Time Features
How to: Display a Control in the Customize Toolbox Dialog Box
Walkthrough: Serializing Collections of Standard Types with the DesignerSerializationVisibilityAttribute
Walkthrough: Inheriting from a Windows Forms Control with Visual C#
How to: Provide a Toolbox Bitmap for a Control
How to: Inherit from Existing Windows Forms Controls
Walkthrough: Debugging Custom Windows Forms Controls at Design Time
How to: Inherit from the Control Class
How to: Test the Run-Time Behavior of a UserControl
How to: Align a Control to the Edges of Forms at Design Time
How to: Inherit from the UserControl ClassWindows Forms Controls
How to: Author Controls for Windows Forms
How to: Author Composite Controls
Walkthrough: Authoring a Composite Control with Visual Basic
Walkthrough: Authoring a Composite Control with Visual C#
Walkthrough: Inheriting from a Windows Forms Control with Visual Basic
How to: Create a Windows Forms Control That Takes Advantage of Design-Time Features.NET Framework: Application Development
How to: Display a Control in the Choose Toolbox Items Dialog BoxWindows Forms Controls
Walkthrough: Serializing Collections of Standard Types with the DesignerSerializationVisibilityAttributeWindows Forms Controls
Walkthrough: Inheriting from a Windows Forms Control with Visual C#Windows Forms Controls
How to: Provide a Toolbox Bitmap for a ControlWindows Forms Controls
How to: Inherit from Existing Windows Forms ControlsWindows Forms Controls
Walkthrough: Debugging Custom Windows Forms Controls at Design TimeWindows Forms Controls
How to: Inherit from the Control ClassWindows Forms Controls
How to: Test the Run-Time Behavior of a UserControlWindows Forms Controls
How to: Align a Control to the Edges of Forms at Design TimeWindows Forms Controls
How to: Inherit from the UserControl ClassWindows Forms Controls
How to: Author Controls for Windows FormsWindows Forms Controls
How to: Author Composite ControlsWindows Forms Controls
Walkthrough: Authoring a Composite Control with Visual BasicWindows Forms Controls
Walkthrough: Authoring a Composite Control with Visual C#Windows Forms Controls
Walkthrough: Inheriting from a Windows Forms Control with Visual BasicWindows Forms Controls
How to: Display a Control in the Choose Toolbox Items Dialog Box
Walkthrough: Serializing Collections of Standard Types with the DesignerSerializationVisibilityAttribute
Walkthrough: Inheriting from a Windows Forms Control with Visual C#
How to: Provide a Toolbox Bitmap for a Control
How to: Inherit from Existing Windows Forms Controls
Walkthrough: Debugging Custom Windows Forms Controls at Design Time
How to: Inherit from the Control Class
How to: Test the Run-Time Behavior of a UserControl
How to: Align a Control to the Edges of Forms at Design Time
How to: Inherit from the UserControl Class
How to: Author Controls for Windows Forms
How to: Author Composite Controls
Walkthrough: Authoring a Composite Control with Visual Basic
Walkthrough: Authoring a Composite Control with Visual C#
Walkthrough: Inheriting from a Windows Forms Control with Visual Basic
How to: Create a Windows Forms Control That Takes Advantage of Design-Time Features
How to: Create a Windows Forms Control That Takes Advantage of Design-Time Features

To set the Dock property for your control at run time

  • Set the Dock property to the appropriate value in code.

    // To set the Dock property internally.
    this.Dock = DockStyle.Top;
    // To set the Dock property from another object.
    UserControl1.Dock = DockStyle.Top;
    
Show:
© 2014 Microsoft