New to Telerik UI for WinForms? Start a free 30-day trial
Customizing Context Menu on DocumentWindow Tabs in RadDock
Updated on Mar 10, 2026
Environment
| Product Version | Product | Author |
|---|---|---|
| 2026.1.210 | RadDock for WinForms | Dinko Krastev |
Description
With this KB article, we will demonstrate how to customize the context menu that appears when right-clicking on DocumentWindow tabs in RadDock. The goal is to replace the default RadDock context menu with a custom menu containing options such as "Add," "Close," "Lock" and "Edit". The Edit menu option triggers inline editing of the tab name.
Solution
Use the built-in ContextMenuService to customize the context menu for DocumentWindow tabs in RadDock. Follow these steps:
- Subscribe to the
ContextMenuDisplayingevent from theContextMenuService. - Clear the default menu items and add custom ones.
- Enable inline editing by calling the
BeginEdit()method on theTabStripElementassociated with the clicked tab.
Here is the complete implementation:
C#
public Form1()
{
InitializeComponent();
// Enable inline editing for the DocumentTabStrip
documentTabStrip2.TabStripElement.AllowEdit = true;
// Subscribe to the ContextMenuDisplaying event
this.radDock1.GetService<ContextMenuService>().ContextMenuDisplaying += RadDock_ContextMenuDisplaying;
}
private void RadDock_ContextMenuDisplaying(object sender, ContextMenuDisplayingEventArgs e)
{
// Check if the context menu is for a DocumentWindow tab
if (e.DockWindow is DocumentWindow)
{
// Clear default menu items
e.MenuItems.Clear();
// Add custom menu items
e.MenuItems.Add(new RadMenuItem("Add"));
e.MenuItems.Add(new RadMenuItem("Close"));
e.MenuItems.Add(new RadMenuItem("Lock"));
// Add "Edit" menu item and attach edit action
RadMenuItem editItem = new RadMenuItem("Edit");
editItem.Click += (s, args) =>
{
var window = (DocumentWindow)e.DockWindow;
window.DockTabStrip.TabStripElement.BeginEdit();
};
e.MenuItems.Add(editItem);
}
}