Back to Devexpress

Showing and Hiding Dock Panels

windowsforms-1264-controls-and-libraries-docking-library-managing-dock-panels-in-code-showing-and-hiding-dock-panels.md

latest3.7 KB
Original Source

Showing and Hiding Dock Panels

  • Oct 29, 2020
  • 2 minutes to read

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.

Showing and Hiding Dock Panels

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.

Example

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).

csharp
int index = 0;
// Iterate through the visible panels which are not owned by other panels.
while(index < dockManager1.RootPanels.Count) {
   DockPanel panel = dockManager1.RootPanels[index];
   // Hide the panel if it's floating.
   if(panel.FloatForm == null)
      index++;
   else
      panel.Hide();
}
vb
Dim index As Integer = 0
' Iterate through the visible panels which are not owned by any other panels.
While index < dockManager1.RootPanels.Count
   Dim panel As DockPanel = dockManager1.RootPanels(index)
   ' Hide the panel if it's floating.
   If (panel.FloatForm Is Nothing) Then
      index = index + 1
   Else
      panel.Hide()
   End If
End While

See Also

Dock Panels

Creating and Destroying Dock Panels

Docking Panels Programmatically