DockManager.AddPanel(DockingStyle) Method
Creates a new dock panel and docks it to the form (user control) using the specified dock style.
Namespace: DevExpress.XtraBars.Docking
Assembly: DevExpress.XtraBars.v24.1.dll
NuGet Package: DevExpress.Win.Navigation
Declaration
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 DockManager’s container control (DockManager.Form). 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. 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.
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.
If a new panel is then docked to the left edge, it will be docked as follows:
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";