ToolStripMenuItem.ShortcutKeys Property

Definition

Gets or sets the shortcut keys associated with the ToolStripMenuItem.

C#
public System.Windows.Forms.Keys ShortcutKeys { get; set; }

Property Value

One of the Keys values. The default is None.

Exceptions

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

Examples

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 a Windows Forms Application.

C#
printToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.P;

Remarks

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.

Applies to

Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

See also