$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
Dock Control for C# WinForms
Create menu items and raise events, modify existing items in WinForms C# applications
Home > WinForms UI Controls > User Manual > Context Menu in C#

Context Menu of Dock Control in C# Windows Forms

The Dock Control for Windows Forms provide a separate service to deal with operations of all context menus. It requires registration of the Dock Control and the Context Menu Service. All context menu requests will be passed to the Context Menu service. With the Context Menu feature, developers can create the appropriate menu items, raises several events, modify existed items, and add their own or even cancel the context menu requests.

How to Modify the Exist Context Menus

To modify or customize the exit context menus, developers can reference to the sample below, which shows how to collapse the options of context menu from the DocumentWindow. First we need to get the Context Menu Service and subscribe to the DisplayContextMenu event.

ContextMenuService menuService = this.WinFormsDock1.GetService<ContextMenuService>();
menuService.DisplayContextMenu += menuService_DisplayContextMenu;
Now it is possible to collapse the Close options of context menu from the DocumentWindow in the DisplayContextMenu event handler:

private void menuService_DisplayContextMenu (object sender, DisplayContextMenuEventArgs e)
if (e.MenuType == ContextMenuType.DockWindow &&
e.DockWindow.DockTabStrip is DocumentTabStrip)
for (int i = 0; i < e.MenuItems.Count; i++)
MenuItemBase menuItem = e.MenuItems[i];
if (menuItem.Name == "CloseWindow" ||
menuItem.Name == "CloseAllButThis" ||
menuItem.Name == "CloseAll" ||
menuItem is MenuSeparatorItem)
menuItem.Enabled = false;
menuItem.Visibility = WinControls.ElementVisibility.Collapsed;

Names of Context Menu Items

The above C# code snippet use the Name properties of the Context Menu Items rather than the Text property so as to let the users handle the case even when applying a custom DockLocalization provider. The Name properties for the Context Menu Items in the Dock Control include
  • Close, CloseWindow
  • Close All But This, CloseAllButThis
  • Close All, CloseAll
  • New Horizontal Tab Group, NewHTabGroup
  • New Vertical Tab Group, NewVTabGroup
  • Floating, Floating
  • Dockable, Docked
  • Tabbed Document, TabbedDocument
  • Auto Hide, AutoHide
  • Hide, Hidden
  • Document Name, ActivateWindow
UI Controlsfor Windows Forms
.NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI Design
WinForms UI Controls