)
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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to Add/ Remove the ContextMenuItem from EditControl Embedded ContextMenu?

Platform: WinForms |
Control: EditControl |
Published Date: February 22, 2018 |
Last Revised Date: May 24, 2019

EditControl has default embedded ContextMenu. This ContextMenu supports to add/remove the ContextMenuItem. It can be achieved using below functions.

 

AddContextMenuItem: Used to add the ContextMenuItem.

 

RemoveContextMenuItem: Used to remove the ContextMenuItem from the Embedded ContextMenu by passing the below corresponding ContextMenuItem Text. Please make use of the below ContextMenuItem Text. 

 

ContextMenuItem 

Corresponding Item Text 


1.Edit  

 

Cut  

Copy 

Paste 

Delete 

Undo 

Redo 

Find… 

Replace… 

Go to… 

Select All 

Delete All 

 

2. File 

 

New 

Open… 

Close 

Save 

Save As… 

Print Preview 

Print 

 

3. Advanced 

 

Tabify Selection 

Untabify Selection 

Indent Selection 

Unindent Selection 

Comment Selection 

Uncomment  

Expand All 

Collapse All 

 

4. Bookmarks 

 

Toggle Bookmark 

Next Bookmark 

Previous Bookmark 

Clear Bookmarks 

 

5. Options…  

 

 

1. &Edit 

 

“Cu&t” 

“Cop&y” 

“&Delete” 

“&Paste” 

“&Undo” 

“R&edo” 

“&Find” 

“&Replace” 

“&Go to…” 

“&Select All” 

“De&lete All” 

 

2. “&File” 

 

“&New” 

“&Open…” 

“&Close” 

“&Save” 

“Save &As..” 

“Print Pre&view” 

“&Print”  

 

3. “&Advanced” 

 

“&Tabify Selection” 

“&Untabify Selection” 

“&Indent Selection” 

“&U&nindent Selection” 

“&Comment Selection” 

“Unc&omment Selection” 

“&Exapnd All” 

“Co&llapse All” 

 

4. “&Bookmarks” 

 

“Toggle Bookmark” 

“Next Bookmark” 

“Previous Bookmark” 

“Clear Bookmarks” 

 

5. “&Options…” 

 

The following code demonstrates the same.

 

C#

// Handle the FillMenu event which is called each time the context menu is displayed.
this.editControl1.ContextMenuManager.FillMenu += ContextMenuManager_FillMenu;
 
//Add ContextMenuItem
this.editControl1.ContextMenuManager.ContextMenuProvider.AddContextMenuItem("&Find", show1);
this.editControl1.ContextMenuManager.ContextMenuProvider.AddContextMenuItem("&Replace", ShowReplaceDialog);
this.editControl1.ContextMenuManager.ContextMenuProvider.AddContextMenuItem("&Goto", ShowGoToDialog);
 
//Remove ContextMenu Item
this.editControl1.ContextMenuManager.ContextMenuProvider.RemoveContextMenuItem("&Edit");
this.editControl1.ContextMenuManager.ContextMenuProvider.RemoveContextMenuItem("&Options…");
this.editControl1.ContextMenuManager.ContextMenuProvider.RemoveContextMenuItem("&Save");
this.editControl1.ContextMenuManager.ContextMenuProvider.RemoveContextMenuItem("Save &As...");
 

 

VB

'Raise the event that used to set Add/Remove the ContextmenuItem
AddHandler Me.editControl1.ContextMenuManager.FillMenu, AddressOf ContextMenuManager_FillMenu
 
''Add ContextMenuItem
Me.editControl1.ContextMenuManager.ContextMenuProvider.AddContextMenuItem("&Find", AddressOf show1)
Me.editControl1.ContextMenuManager.ContextMenuProvider.AddContextMenuItem("&Replace", AddressOf ShowReplaceDialog)
Me.editControl1.ContextMenuManager.ContextMenuProvider.AddContextMenuItem("&Goto", AddressOf ShowGoToDialog)
 
'Remove ContextMenu Item
Me.editControl1.ContextMenuManager.ContextMenuProvider.RemoveContextMenuItem("&New")
Me.editControl1.ContextMenuManager.ContextMenuProvider.RemoveContextMenuItem("&Options...")
Me.editControl1.ContextMenuManager.ContextMenuProvider.RemoveContextMenuItem(“Cop&y”)
Me.editControl1.ContextMenuManager.ContextMenuProvider.RemoveContextMenuItem("Save &As...")  
 

 

Screenshot

 

Showing default ContextMenu

Figure 1: Default ContextMenu.

 

Showing after remove Save As from  File ContextMenuItem

Figure 2: After Remove Save As... from File ContextMenu Item.

 

Samples:

 

C#:  EditControlSample

VB:  EditControlSample

 

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

Live Chat Icon For mobile
Live Chat Icon