We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to remove the menu item from docked window context menu in DockingManager?

Context menu items in dock window caption can be customized using DockContextMenu event of DockingManager. The DockContextMenuEventArgs allows to add/remove the menu items using its ContextMenu option.  So, we can add/remove the ContextMenuItem by passing the corresponding BarItem to add/remove function.


Here we have added the new menu item "File" and removed the default menu items “Hide” and “Dock to”.  Please make use of the below ContextMenuItemText for remove the default menu items from context menu. 



Corresponding BarItem Text



MDI Child



Dock to



&MDI Child



Dock to


The following code demonstrates the same.


//Add/Remove ContextMenu
this.dockingManager1.DockContextMenu += DockingManager1_DockContextMenu;
private void DockingManager1_DockContextMenu(object sender, DockContextMenuEventArgs arg)
///Add ContextMenuItem
//Initialize and set the properties.
this.fileItem = new Syncfusion.Windows.Forms.Tools.XPMenus.ParentBarItem();
this.bar1 = new Syncfusion.Windows.Forms.Tools.XPMenus.BarItem();
this.fileItem.Text = "File";
this.bar1.Text = "Exit";
this.fileItem.Items.AddRange(new Syncfusion.Windows.Forms.Tools.XPMenus.BarItem[] { this.bar1 });
//Remove ContextMenuItem
BarItem item = arg.ContextMenu.ParentBarItem.Items[4] as BarItem;
BarItem item1 = arg.ContextMenu.ParentBarItem.Items[5] as BarItem;
if (item != null && item.Text == "&Hide")
if (item1 != null && item1.Text == "Dock to")


'Add/Remove ContextMenu
AddHandler Me.dockingManager1.DockContextMenu, AddressOf DockingManager1_DockContextMenu
'''Add ContextMenuItem
'Initialize and set the properties.
Me.fileItem = New Syncfusion.Windows.Forms.Tools.XPMenus.ParentBarItem()
Me.bar1 = New Syncfusion.Windows.Forms.Tools.XPMenus.BarItem()
Me.fileItem.Text = "File"
Me.bar1.Text = "Exit"
Me.fileItem.Items.AddRange(New Syncfusion.Windows.Forms.Tools.XPMenus.BarItem() { Me.bar1 })
'Remove ContextMenuItem
Dim item As BarItem = TryCast(arg.ContextMenu.ParentBarItem.Items(4), BarItem)
Dim item1 As BarItem = TryCast(arg.ContextMenu.ParentBarItem.Items(5), BarItem)
If item IsNot Nothing AndAlso item.Text = "&Hide" Then
End If
If item1 IsNot Nothing AndAlso item1.Text = "Dock to" Then
End If




Default contextmenu

Figure 1: Default ContextMenu


Showing add or remove contextmenuitem

Figure 2: After add/remove ContextMenuItem.




C#:  DockingManagerExample


VB:  DockingManagerExample


2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile