Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Collapse]Docking Library
   [Expand]Panels and Panel Containers
    Header Buttons
   [Expand]Managing Dock Panels in Code
    Saving and Restoring the Layout of Dock Panels
   [Collapse]Examples
     How to: Access auto-hidden panels
     How to: Add controls to a panel
     How to: Combine panels into a split container
     How to: Combine panels into a tab container
     How to: Create a dock panel
     How to: Create and float a panel
     How to: Display all the hidden panels
     How to: Dock panels to a form
     How to: Enable the auto hide feature for root panels
     How to: Override the default behavior of a panel when it is closed
     How to: Prevent dock panels from being docked to the form's right edge
     How to: Recursively iterate through the child panels of a specific panel
     How to: Transform a split container into a tab container
     How to: Write and read a docking layout to and from an XML file
     How to: Write and read a docking layout to and from memory
     How to: Write and read a docking layout to and from the system registry
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

How to: Dock panels to a form

Expanded Example 1

In the following code two floating panels are created and then docked to the form referred to by the dock manager's DockManager.Form property. To dock a panel to a form the DockPanel.DockTo method is used.

The order in which the panels are docked determines the layout of dock panels within the form. The first panel will occupy the form's left edge entirely, while the second panel will be docked only within the region not occupied by the first panel.

The result is shown below:

Expanded Example 2

In the following code two panels are created and docked to the form's left and bottom edges respectively. Then a new floating panel is created, this is docked to the form's bottom edge so that it occupies this edge entirely. Panels are docked to the form via the DockPanel.DockTo method.

To dock a panel in a specific position amongst the existing panels, you need to use the DockPanel.DockTo overload which takes the index parameter. If index is set to 0, the panel will completely occupy the corresponding edge of the form.

The result is shown below:

How would you rate this topic?​​​​​​​