Skip to main content

How to: Combine panels into a split container

  • 2 minutes to read

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);