Back to Devexpress

How to: Transform a split container into a tab container

windowsforms-5441-controls-and-libraries-docking-library-examples-how-to-transform-a-split-container-into-a-tab-container.md

latest2.2 KB
Original Source

How to: Transform a split container into a tab container

  • Nov 13, 2018
  • 2 minutes to read

In the following example three panels are created and docked to form a split container. Then the DockPanel.Tabbed property of the split container is set to true and this transforms the split container into a tab container. The result is shown below:

csharp
using DevExpress.XtraBars.Docking;
// ...
// Create a panel and dock it to the left edge of the form.
DockPanel p1 = dockManager1.AddPanel(DockingStyle.Left);
p1.Text = "Panel 1";
// Add a button to the panel.
DevExpress.XtraEditors.SimpleButton btn = new DevExpress.XtraEditors.SimpleButton();
btn.Text = "Print...";
p1.ControlContainer.Controls.Add(btn);

// Add a new panel to the first panel. This forms a split container.
DockPanel p2 = p1.AddPanel();
p2.Text = "Panel 2";

// Add a new panel to the split container.
DockPanel p3 = p1.ParentPanel.AddPanel();
p3.Text = "Panel 3";
// ...

// Transform the split container into a tab container.
p1.ParentPanel.Tabbed = true;
vb
Imports DevExpress.XtraBars.Docking
' ...
' Create a panel and dock it to the left edge of the form.
Dim p1 As DockPanel = DockManager1.AddPanel(DockingStyle.Left)
p1.Text = "Panel 1"
' Add a button to the panel
Dim btn As DevExpress.XtraEditors.SimpleButton btn = New DevExpress.XtraEditors.SimpleButton()
btn.Text = "Print..."
p1.ControlContainer.Controls.Add(btn)

' Add a new panel to the first panel. This forms a split container.
Dim p2 As DockPanel = p1.AddPanel()
p2.Text = "Panel 2"

' Add a new panel to the split container.
Dim p3 As DockPanel = p1.ParentPanel.AddPanel()
p3.Text = "Panel 3"
'...

' Transform the split container into a tab container.
p1.ParentPanel.Tabbed = True