This topic describes how you can show and hide dock panels via code. For information on creating and destroying dock panels, refer to the Creating and Destroying Dock Panels topic.
A dock panel's visibility is controlled by its DockPanel.Visibility property. If this property is set to DockVisibility.Visible the panel is visible. If this property is set to DockVisibility.Hidden then the panel is not displayed on screen (it's hidden).
For panels docked to the form and their child panels the DockPanel.Visibility property can be set to DockVisibility.AutoHide. This enables the auto-hide functionality for the panel. For floating panels setting the DockPanel.Visibility property to DockVisibility.AutoHide has no effect.
To display a hidden panel, you can also call its DockPanel.Show method. This method sets the panel's DockPanel.Visibility property to DockVisibility.Visible. If it's necessary to hide a dock panel, you can call its DockPanel.Hide method.
Indexed access to hidden panels is provided via the DockManager.HiddenPanels collection.
The following code demonstrates how to hide all the visible floating panels. The visible floating panels are accessed via the DockManager.RootPanels collection. For such panels the DockPanel.FloatForm property refers to a valid object (floating form).
C# |
int index = 0;
while(index < dockManager1.RootPanels.Count) {
DockPanel panel = dockManager1.RootPanels[index];
if(panel.FloatForm == null)
index++;
else
panel.Hide();
}
|
VB |
Dim index As Integer = 0
While index < dockManager1.RootPanels.Count
Dim panel As DockPanel = dockManager1.RootPanels(index)
If (panel.FloatForm Is Nothing) Then
index = index + 1
Else
panel.Hide()
End If
End While
|