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

DockManager.AddPanel(DockingStyle) Method

Creates a new dock panel and docks it to the form (user control) using the specified style.

Namespace: DevExpress.XtraBars.Docking

Assembly: DevExpress.XtraBars.v19.1.dll

Declaration

public DockPanel AddPanel(
    DockingStyle dock
)

Parameters

Name Type Description
dock DockingStyle

The DockingStyle value specifying how the created panel is docked to the container control.

Returns

Type Description
DockPanel

A DockPanel object created by this method.

Remarks

The panel created by this method is docked to the container control referred to by the DockManager.Form property. The DockManager.Form property must refer to a valid object (not null), otherwise an exception will occur when this method is called.

The dock parameter specifies how the panel is docked. If the dock parameter is set to DockingStyle.Float the panel will float.

If the dock parameter is set to DockingStyle.Left, DockingStyle.Top, DockingStyle.Right or DockingStyle.Bottom the panel is docked to the corresponding edge of the container control.

A dock panel cannot be created and docked to a form when its dock style is set to DockingStyle.Fill. That is a panel cannot be created so that it occupies all of the form. If the dock parameter is set to DockingStyle.Fill, no panel is created and the AddPanel method returns null (Nothing in Visual Basic).

The order in which the AddPanel method is called to create dock panels is important since it affects the order of the panels within the container control. The first panel docked to the left for instance, will occupy the left edge of the container control. The second panel docked to the top will occupy the top edge of the container control which is not occupied by the first panel, etc.

DockPanel_Index_2Panels

If a new panel is then docked to the left edge, it will be docked as follows:

DockManager_AddPanel_3Panels

Thus new panels are added to the panel’s collection so that they occupy the corresponding edge of the container control’s empty region. A panel’s DockPanel.Index property specifies the position of the panel amongst the other panels residing on the same parent control. To dock a panel to a specific position within the panels’ collection, use the DockPanel.DockTo overload which takes the dock and index parameters. For more information on the order of panels within the parent see the DockPanel.Index topic.

Visible panels that have been created and docked by the AddPanel method can be obtained via the DockManager.RootPanels collection. This collection does not include hidden panels, panels whose auto-hide functionality is enabled and panels which are docked to other panels.

Example

The following code shows how to add a dock manager to a form and create a panel.

using DevExpress.XtraBars.Docking;
// ...
// Create a dock manager
DockManager dm = new DockManager();
// Specify the form to which the dock panels will be added
dm.Form = this;
// Create a new panel and dock it to the left edge of the form
DockPanel dp1 = dm.AddPanel(DockingStyle.Left);
dp1.Text = "Panel 1";

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the AddPanel(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