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. (Last updated on: November 16, 2018).
Close Icon
Unfortunately, activation email could not send to your email. Please try again.
Close Icon
close icon
Vote for your favorite ebook
Succinctly Readers Awards 2020
Syncfusion Feedback

How to add cascading menu items to the context menu in WinForms SyntaxEditor (EditControl)?

Platform: WinForms |
Control: EditControl |
Published Date: April 30, 2011 |
Last Revised Date: December 13, 2019

Cascading menu

The context menu in Essential Edit can be populated with cascading menu items by handling the MenuFill event and adding the menu items to the IContextMenuProvider object associated with the EditControl as shown in code below.

C#

private void editControl1_MenuFill(object sender, System.EventArgs e)
{
    ContextMenuManager cmm = sender as ContextMenuManager;
    // Add a menu item to the context menu
    cmm.AddMenuItem("Bookmarks",new EventHandler(ToggleBookmark));
    // Add child menu items to the earlier menu item
    IContextMenuProvider contextMenuProvider =  this.editControl1.ContextMenuManager.ContextMenuProvider as IContextMenuProvider;
    contextMenuProvider.AddContextMenuItem("Bookmarks","Toggle Bookmarks",new EventHandler(ToggleBookmark));
    contextMenuProvider.AddContextMenuItem("Bookmarks","Clear Bookmarks",new EventHandler(ClearBookmarks));
    // Add a second level of child menu items to the earlier child menu item
    contextMenuProvider.AddContextMenuItem("Clear Bookmarks", "ClearAll", new EventHandler(ClearAllBookmarks));
    contextMenuProvider.AddContextMenuItem("Clear Bookmarks", "Clear", new EventHandler(ClearBookmark));
}

 

VB

Private Sub editControl1_MenuFill(sender As Object, e As System.EventArgs) Handles editControl1.MenuFill
    Dim cmm As ContextMenuManager = sender
    ' Add a menu item to the context menu
    cmm.AddMenuItem("Bookmarks", New EventHandler(AddressOf ToggleBookmark))
    ' Add child menu items to the earlier menu item
    Dim contextMenuProvider As IContextMenuProvider =  Me.editControl1.ContextMenuManager.ContextMenuProvider
    contextMenuProvider.AddContextMenuItem("Bookmarks", "Toggle Bookmarks", New EventHandler(AddressOf ToggleBookmark))
    contextMenuProvider.AddContextMenuItem("Bookmarks", "Clear Bookmarks", New EventHandler(AddressOf ClearBookmarks))
    ' Add a second level of child menu items to the earlier child menu item
contextMenuProvider.AddContextMenuItem("Clear Bookmarks", "ClearAll", New  EventHandler(AddressOf ClearAllBookmarks))
    contextMenuProvider.AddContextMenuItem("Clear Bookmarks", "Clear", New EventHandler(AddressOf ClearBookmark))
End Sub 'editControl1_MenuFill

 

Reference link: https://help.syncfusion.com/windowsforms/syntax-editor/editing

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
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