)
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 assign shortcut keys for context menu items in the EditControl?

Platform: WinForms |
Control: EditControl |
Published Date: July 28, 2015 |
Last Revised Date: May 24, 2019

In EditControl, Context Menu is displayed on mouse right click. The context menu items can be customized by using the MenuFill event handler and context menu items are specified with some default shortcut keys. However, the shortcut keys of the context menu items can be customized by using the function, SetContextMenuItemShortcut in the IContextMenuProvider interface.

The following code example demonstrates the same.

C#

//Customizes the context menu items
this.editControl1.MenuFill += editControl1_MenuFill;
void editControl1_MenuFill(object sender, EventArgs e)
{
    Syncfusion.Windows.Forms.IContextMenuProvider contextMenuProvider = this.editControl1.ContextMenuManager.ContextMenuProvider;
    //Specifies the shortcut key for context menu item.
    contextMenuProvider.SetContextMenuItemShortcut("Cu&t", Shortcut.CtrlX);
    contextMenuProvider.SetContextMenuItemShortcut("Cop&y", Shortcut.CtrlC);
    contextMenuProvider.SetContextMenuItemShortcut("&Paste", Shortcut.CtrlV);
}

VB

'Customizes the context menu items
AddHandler Me.editControl1.MenuFill, AddressOf editControl1_MenuFill
Private Sub editControl1_MenuFill(ByVal sender As Object, ByVal e As EventArgs)
 Dim contextMenuProvider As Syncfusion.Windows.Forms.IContextMenuProvider = Me.editControl1.ContextMenuManager.ContextMenuProvider
 'Specifies the shortcut key for context menu item.
 contextMenuProvider.SetContextMenuItemShortcut("Cu&t", Shortcut.CtrlX)
 contextMenuProvider.SetContextMenuItemShortcut("Cop&y", Shortcut.CtrlC)
 contextMenuProvider.SetContextMenuItemShortcut("&Paste", Shortcut.CtrlV)
End Sub

 

Default shortcut key for context menu items

Figure 1: Default shortcut key for context menu items in the EditControl

Shortcut modified for context menu items

Figure 2: Shortcut modified for context menu items in the EditControl

 

Sample Links:

C#: http://www.syncfusion.com/downloads/support/directtrac/118553/ze/EditControlContextMenu805343499

VB: http://www.syncfusion.com/downloads/support/directtrac/118553/ze/EditControlContextMenu_VB1257950720

 

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