MenuItem::Shortcut Property
Gets or sets a value indicating the shortcut key associated with the menu item.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
| Exception | Condition |
|---|---|
| InvalidEnumArgumentException | The assigned value is not one of the Shortcut values. |
The following code example creates a menu item, sets the caption, assigns a shortcut key, makes the menu item visible, and shows the shortcut key display for the menu item. The example requires that a MenuItem has been created that is named menuItem1.
public: void SetupMyMenuItem() { // Set the caption for the menu item. menuItem1->Text = "&New"; // Assign a shortcut key. menuItem1->Shortcut = Shortcut::CtrlN; // Make the menu item visible. menuItem1->Visible = true; // Display the shortcut key combination. menuItem1->ShowShortcut = true; }
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.