Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to: Override the default behavior of a panel when it is closed

  • 2 minutes to read

In the following example the DockManager.ClosingPanel event is handled to override the default behavior of the panel when it is closed. The panel being closed will be docked to the bottom edge of the form and its auto-hide functionality will be enabled.

using DevExpress.XtraBars.Docking;
// ...
// Checks if a panel is auto-hidden to the form's bottom edge.
bool IsPanelAutoHiddenBottom(DockPanel panel) {
   AutoHideContainer bottomContainer = 
     panel.DockManager.AutoHideContainers[DockingStyle.Bottom];
   if(bottomContainer == null) return false;
   return bottomContainer.Contains(panel);
}

private void dockManager1_ClosingPanel(object sender, DockPanelCancelEventArgs e) {
   // Cancel the default closing mechanism.
   e.Cancel = true;
   if(IsPanelAutoHiddenBottom(e.Panel)) return;
   // Disable the auto-hide functionality if the panel is auto-hidden.
   if(e.Panel.Visibility == DockVisibility.AutoHide)
      e.Panel.Visibility = DockVisibility.Visible;
   // Dock the panel to the bottom edge of the form and enable its auto-hide functionality.
   e.Panel.DockTo(DockingStyle.Bottom);
   e.Panel.Visibility = DockVisibility.AutoHide;
}