ToolStripMenuItem.ShortcutKeys Property

Gets or sets the shortcut keys associated with the ToolStripMenuItem.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

[LocalizableAttribute(true)] 
public Keys ShortcutKeys { get; set; }
/** @property */
public Keys get_ShortcutKeys ()

/** @property */
public void set_ShortcutKeys (Keys value)

public function get ShortcutKeys () : Keys

public function set ShortcutKeys (value : Keys)

Not applicable.

Property Value

One of the Keys values. The default is None.

Exception typeCondition

InvalidEnumArgumentException

The property was not set to one of the Keys values.

Use the ShortcutKeys property to assign a key combination to a menu command, such as CTRL+C for the Copy command. You can use shortcut keys instead of or in addition to access keys, which are underscored letters in menus or menu items used with the ALT key. Define access keys in code by typing an ampersand (&) before the letter you want to use for an access key.

The following code example demonstrates how to use the ShortcutKeys property to assign the key combination CTRL+P to a menu item called printToolStripMenuItem. For the complete example, see How to: Add Web Browser Capabilities to Your Windows Forms Application.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show: