Skip to main content

DockPanel.DockTo(DockPanel) Method

Docks the current panel to the specified panel.

Namespace: DevExpress.XtraBars.Docking

Assembly: DevExpress.XtraBars.v24.1.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

public void DockTo(
    DockPanel panel
)

Parameters

Name Type Description
panel DockPanel

A DockPanel object representing the target dock panel.

Remarks

If the target panel is a split container or tab container, the current panel is 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.

This DockTo overload appends the current panel to the target container, i.e., the current panel is added at the last position among the container’s children. To add a panel to a specific position, use the DockPanel.DockTo overload which takes an index parameter.

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