.NET Framework Class Library
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)
Syntax

Visual Basic (Declaration)
Public Property ShortcutKeys As Keys
Visual Basic (Usage)
Dim instance As ToolStripMenuItem
Dim value As Keys

value = instance.ShortcutKeys

instance.ShortcutKeys = value
C#
public Keys ShortcutKeys { get; set; }
Visual C++
public:
property Keys ShortcutKeys {
    Keys get ();
    void set (Keys value);
}
JScript
public function get ShortcutKeys () : Keys
public function set ShortcutKeys (value : Keys)

Property Value

Type: System.Windows.Forms..::.Keys
One of the Keys values. The default is None.
Exceptions

ExceptionCondition
InvalidEnumArgumentException

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

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.

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.

Visual Basic
printToolStripMenuItem.ShortcutKeys = Keys.Control Or Keys.P
C#
printToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.P;
Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 3.5, 3.0, 2.0
See Also

Reference

Other Resources

Tags :


Page view tracker