Showing and Hiding Dock Panels

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


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();
}
See Also