WinForms › Header Control › HeaderContextMenuAboutToBeDisplayedHandler
HeaderContextMenuAboutToBeDisplayedHandler
delegate.NET 6 / 8 / 10.NET Framework 4.8Binarymission.WinForms.Controls.NavigationControls
Represents the method that handles BinaryHeaderControl.HeaderContextMenuAboutToBeDisplayed,
and can stop the header's context menu from opening.
public delegate void HeaderContextMenuAboutToBeDisplayedHandler(object sender, ref bool cancel);
Remarks
The handler runs before the menu is shown, so it is the place to enable, disable or fill the menu's items for the current state of the application, or to cancel the menu altogether.
Examples
header.HeaderContextMenuAboutToBeDisplayed += OnFoldersMenuOpening;
private void OnFoldersMenuOpening(object sender, ref bool cancel)
{
// No folder selected: there is nothing for the menu to act on.
cancel = foldersTree.SelectedNode == null;
deleteFolderItem.Enabled = foldersTree.SelectedNode?.Parent != null;
}