Files
docs-desktop/dotnet-desktop-guide/framework/winforms/controls/how-to-dock-controls-on-windows-forms.md
T
Andy De George c0ba284473 Initial winforms content migrated (#18)
* Merge winforms framework content to working branch (#14)

* Breadcrumb / TOC / Move net5 to net folder (#15)

* change path from net5 to net

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Add .net 5 winforms placeholder article (#16)

* added some metadata and adjusted net5 placeholder

* corrections

* corrections

* corrections

* Test1

* Swapping landing page vs concept

* fix links

* Fix links

* Fix desc
2020-09-01 16:26:21 -07:00

2.6 KiB

title, ms.date, helpviewer_keywords, ms.assetid, author, ms.author, manager
title ms.date helpviewer_keywords ms.assetid author ms.author manager
Dock Controls 03/30/2017
controls [Windows Forms], docking
Explorer-style applications [Windows Forms], creating
Windows Forms controls, filling client area
bc11f2e4-e90a-4830-b0e2-f43b6e2b8bec jillre jillfra jillfra

How to: Dock controls on Windows Forms

You can dock controls to the edges of your form or have them fill the control's container (either a form or a container control). For example, Windows Explorer docks its xref:System.Windows.Forms.TreeView control to the left side of the window and its xref:System.Windows.Forms.ListView control to the right side of the window. Use the xref:System.Windows.Forms.Control.Dock%2A property for all visible Windows Forms controls to define the docking mode.

Note

Controls are docked in reverse z-order.

The xref:System.Windows.Forms.Control.Dock%2A property interacts with the xref:System.Windows.Forms.Control.AutoSize%2A property. For more information, see AutoSize Property Overview.

To dock a control

  1. In Visual Studio, select the control that you want to dock.

  2. In the Properties window, click the arrow to the right of the xref:System.Windows.Forms.Control.Dock%2A property.

    An editor is displayed that shows a series of boxes representing the edges and the center of the form.

  3. Click the button that represents the edge of the form where you want to dock the control. To fill the contents of the control's form or container control, click the center box. Click (none) to disable docking.

    The control is automatically resized to fit the boundaries of the docked edge.

    Note

    Inherited controls must be Protected to be able to be docked. To change the access level of a control, set its Modifier property in the Properties window.

See also