DockPanel.DockTo(DockingStyle, Int32) Method
Docks the current panel to the form (user control) at the specified position using the specified style.
public void DockTo( DockingStyle dock, int index )
Public Sub DockTo( dock As DockingStyle, index As Integer )
A DockingStyle value specifying how the panel is docked to the form (user control).
A zero-based integer specifying the position at which to dock the current panel.
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 a 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 moves the current panel within the DockManager.RootPanels collection to the position specified by the index parameter and this defines the panel's position amongst the other panels in the form.
If the index parameter is 0 and the form already contains panels, the current panel will be docked to the form's corresponding edge so that it occupies this edge entirely and the existing panels will then be placed within the form's remaining region. In the following image a panel is docked to the top by setting its index to 0.
If the index parameter is 1 the current panel is docked to the corresponding edge within the region not occupied by the panel whose index is 0. In the following image a panel is docked to the top by setting its index to 1.
If the index parameter is 2 the current panel is docked to the corresponding edge within the region not occupied by the panels whose indexes are 0 and 1, etc. In the following image a panel is docked to the right by setting its index to 2.
At any time, a panel's position can be identified via the DockPanel.Index property. Refer to this topic for more information on how panels are arranged within the form.
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:
using DevExpress.XtraBars.Docking; // Create two floating panels. DockPanel dp1 = dockManager1.AddPanel(DockingStyle.Float); dp1.Text = "Panel 1"; DockPanel dp2 = dockManager1.AddPanel(DockingStyle.Float); dp2.Text = "Panel 2"; // Dock the first panel on the left dp1.DockTo(DockingStyle.Left); // Dock the second panel to the bottom. // This panel will be docked within the form's area that isn't occupied by the first panel. dp2.DockTo(DockingStyle.Bottom); // Create a floating panel. DockPanel dp3 = dockManager1.AddPanel(DockingStyle.Float); dp3.Text = "Panel 3"; // Dock this panel so that it occupies the form's bottom edge entirely. dp3.DockTo(DockingStyle.Bottom, 0);