Skip to main content

DockPanel.DockTo(DockPanel, Int32) Method

Docks the current panel to the specified panel in the specified position.

Namespace: DevExpress.XtraBars.Docking

Assembly: DevExpress.XtraBars.v24.1.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

public void DockTo(
    DockPanel panel,
    int index
)

Parameters

Name Type Description
panel DockPanel

A DockPanel object representing the target dock panel.

index Int32

A zero-based integer specifying the position at which to dock the current panel.

Remarks

If the current panel is docked to a split container or tab container, it’s added as a new child to this container.

If the target panel does not contain children, a split container is created in place of the target panel. The split container will display both the target and current panel.

The index parameter specifies the position in which the current panel is docked. Set the index parameter to 0 to add the panel as the first one amongst the target container’s children. Set index to 1 to add the panel as the second one, etc. Setting the index parameter to -1appends the panel to the container. To get the position of a panel amongst its sibling panels, use the DockPanel.Index property.

Note

Example

The following code creates two panels. One panel is docked to the left edge of the form, the second one is floating. The floating panel is then docked to the first panel and this creates a split container.

Then a new floating panel is created. It’s then added as a new item to the created split container at the first position. In this example panels are docked to other panels via the DockPanel.DockTo method. However it’s also possible to create and dock a panel to another panel via the DockPanel.AddPanel method.

The result is shown below:

DockPanel.DockTo_panel_ex

using DevExpress.XtraBars.Docking;
// ...
// Create two panels.
DockPanel dp1 = dockManager1.AddPanel(DockingStyle.Left);
dp1.Text = "Panel 1";         
DockPanel dp2 = dockManager1.AddPanel(DockingStyle.Float);
dp2.Text = "Panel 2";
// Dock the dp2 panel to the dp1 panel. This will create a split container.
dp2.DockTo(dp1);

// Create a floating panel.
DockPanel dp3 = dockManager1.AddPanel(DockingStyle.Float);
dp3.Text = "Panel 3";
// Dock this panel to the split container at the first position.
dp3.DockTo(dp1.ParentPanel, 0);
See Also