DockPanel.DockTo(DockingStyle) Method
Docks the current panel to the form (or user control) using the specified style.
Namespace: DevExpress.XtraBars.Docking
Assembly: DevExpress.XtraBars.v24.2.dll
Declaration
Parameters
Name | Type | Description |
---|---|---|
dock | DockingStyle | A DockingStyle value specifying how the panel is docked to the form (user control). |
Remarks
The DockTo method docks the current panel to the DockManager’s container (form/user control referred to by the DockManager.Form property).
The dock parameter specifies how the panel is docked. It can be set to the following values.
- DockingStyle.Top, DockingStyle.Left, DockingStyle.Bottom or DockingStyle.Right - A panel will be docked to the target form’s corresponding edge.
- DockingStyle.Float - A panel will be floating.
- DockingStyle.Fill - A panel will be docked to the target form’s center. Ensure the DockingOptions.AllowDockToCenter property is enabled.
Panels are arranged within the form according to these panels’ indexes. A panel’s index matches the position of the panel in the DockManager.RootPanels collection. Panels with low indexes are placed nearer the form’s edges. Panels with higher indexes are placed nearer the form’s center.
The DockTo method appends the current panel to this collection and thus the panel will be displayed closest to the form’s center. To dock a panel at a specific position within the form, use the DockPanel.DockTo overload which takes the index parameter. For more information on the layout of panels within the form, refer to the DockPanel.Index property.
Note
- If a panel is docked into a DocumentManager’s TabbedView,
DockTo
methods do not affect this panel until you set its DockPanel.DockedAsTabbedDocument property tofalse
.
Example
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:
using DevExpress.XtraBars.Docking;
// Create two floating panels.
DockPanel dp1 = DockManager1.AddPanel(DockingStyle.Float);
dp1.Text = "dockPanel3";
DockPanel dp2 = DockManager1.AddPanel(DockingStyle.Float);
dp2.Text = "dockPanel1";
// Dock the first panel to left.
dp1.DockTo(DockingStyle.Left);
// Dock the second panel to bottom.
// This panel will be docked within the form's area that isn't occupied by the first panel.
dp2.DockTo(DockingStyle.Bottom);