DockPanel.DockAsTab(DockPanel, Int32) Method
Creates a tab which contains the current panel at the specified position within the target tab container. The target tab container is created if required.
Namespace: DevExpress.XtraBars.Docking
Assembly: DevExpress.XtraBars.v24.1.dll
NuGet Package: DevExpress.Win.Navigation
Declaration
Parameters
Name | Type | Description |
---|---|---|
panel | DockPanel | A DockPanel object representing the target tab container, the target tab container’s tab or the panel that points to the location at which the target tab container will be created. |
index | Int32 | A zero-based integer specifying the position at which the created tab is placed. |
Remarks
If the target dock panel represents a tab container or a tab container’s tab, then the current panel is added to this tab container.
Otherwise, the DockAsTab method creates a tab container, and adds this to the container containing the current and target panels, instead.
If the current panel represents a tab container or a split container, then this container breaks apart and all its children are added as individual tabs to the target tab container. Similarly, if the target panel represents a split container, it will also break apart and all its children are then added to the target tab container as individual pages, along with the current panel (current panel’s children).
The index parameter specifies the position in the target tab container at which the current panel and the current panel’s children are inserted. Set index to 0 to insert the current panel in the first position. Set index to 1 to insert the current panel in the second position within the tab container, etc. Setting index to -1 allows you to add the current panel as the last tab page.
To get the panel’s position amongst its sibling panels, use the DockPanel.Index property.
Example
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:
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);