Back to Devexpress

DockPanel.ParentPanel Property

windowsforms-devexpress-dot-xtrabars-dot-docking-dot-dockpanel-89ce3ad4.md

latest4.3 KB
Original Source

DockPanel.ParentPanel Property

Gets the immediate parent panel of the current panel.

Namespace : DevExpress.XtraBars.Docking

Assembly : DevExpress.XtraBars.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[Browsable(false)]
public DockPanel ParentPanel { get; }
vb
<Browsable(False)>
Public ReadOnly Property ParentPanel As DockPanel

Property Value

TypeDescription
DockPanel

A DockPanel object representing the immediate parent panel of the current panel. null if the panel does not belong to any dock panel.

|

Remarks

Panels can be added to other panels by forming split or tab containers. The ParentPanel property allows you to access the immediate parent panel of the current panel. If the panel does not belong to any panel, this property returns null.

If a panel belongs to a specific panel which in turn belongs to another panel, etc, then the DockPanel.RootPanel property can be used to get the panel’s primary parent panel (the root panel which is not owned by any other panel).

Example

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

See Also

Item[Int32]

RootPanel

RootPanels

DockPanel Class

DockPanel Members

DevExpress.XtraBars.Docking Namespace