Back to Devexpress

How to: Combine panels into a tab container

windowsforms-5436-controls-and-libraries-docking-library-examples-how-to-combine-panels-into-a-tab-container.md

latest1.7 KB
Original Source

How to: Combine panels into a tab container

  • Nov 13, 2018

In the following code two floating panels are created and then combined to form a single tab container. A tab container is created via the DockPanel.DockAsTab method and this method can be used to create new tabs in the created tab container later on.

Which tab in the tab container contains which panel is specified by this method’s index parameter. In this example, the tab page containing the second panel (dp2) will be added to the first tab because the index parameter is set to 0.

The result is shown below:

csharp
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";
// Create a tab container consisting of these panels. 
// Panel dp2 will be displayed within the first tab.
dp2.DockAsTab(dp1, 0);
vb
Imports DevExpress.XtraBars.Docking
' ...
' Create two floating panels.
Dim dp1 As DockPanel = DockManager1.AddPanel(DockingStyle.Float)
dp1.Text = "Panel 1"
Dim dp2 As DockPanel = DockManager1.AddPanel(DockingStyle.Float)
dp2.Text = "Panel 2"
' Create a tab container consisting of these panels. 
' Panel dp2 will be displayed within the first tab.
dp2.DockAsTab(dp1, 0)