Skip to main content
A newer version of this page is available. .

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.v19.1.dll

Declaration

public void DockTo(
    DockingStyle dock
)

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 form (user control) which is referred to by the DockManager.Form property.

The dock parameter specifies how the dock panel is docked. Set dock to DockingStyle.Top, DockingStyle.Left, DockingStyle.Bottom or DockingStyle.Right to dock the current panel to the corresponding edge of the form. Set dock to DockingStyle.Float to make the panel floating.

A dock panel’s dock style cannot be set to Fill when it’s residing within a form, that is a panel cannot occupy the form entirely. Consequently the DockTo method does nothing if the dock parameter is set to DockingStyle.Fill.

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.

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:

DockPanel.DockTo_style_ex

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);

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the DockTo(DockingStyle) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also