Export (0) Print
Expand All

MenuItem.ShowShortcut Property

Gets or sets a value indicating whether the shortcut key that is associated with the menu item is displayed next to the menu item caption.

[Visual Basic]
Public Property ShowShortcut As Boolean
[C#]
public bool ShowShortcut {get; set;}
[C++]
public: __property bool get_ShowShortcut();
public: __property void set_ShowShortcut(bool);
[JScript]
public function get ShowShortcut() : Boolean;
public function set ShowShortcut(Boolean);

Property Value

true if the shortcut key combination is displayed next to the menu item caption; false if the shortcut key combination is not to be displayed. The default is true.

Remarks

You can use this property to provide the option for users to hide shortcuts from menus to conserve menu space or to hide a shortcut key from being displayed.

Example

[Visual Basic, C#, C++] The following 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 assumes a MenuItem object has been created that is named menuItem1.

[Visual Basic] 
Public Sub 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
End Sub


[C#] 
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;
}
  

[C++] 
public:
 void SetupMyMenuItem()
 {
    // Set the caption for the menu item.
    menuItem1->Text = S"&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;
 }
   

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

MenuItem Class | MenuItem Members | System.Windows.Forms Namespace | Shortcut

Show:
© 2014 Microsoft