Share via


MenuItem.ShowShortcut 屬性

定義

取得或設定值,指出功能表項目標題的旁邊是否顯示出與功能表項目相關的快速鍵。

public:
 property bool ShowShortcut { bool get(); void set(bool value); };
public bool ShowShortcut { get; set; }
member this.ShowShortcut : bool with get, set
Public Property ShowShortcut As Boolean

屬性值

Boolean

如果功能表項目標題的旁邊顯示快速組合鍵,則為 true;不顯示快速組合鍵,則為 false。 預設為 true

範例

下列程式碼範例會建立功能表項目、設定標題、指派快速鍵、讓功能表項目可見,並顯示功能表項目的快速鍵顯示。 此範例要求 MenuItem 已建立名為 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;
   }
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;
}
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

備註

您可以使用這個屬性來提供選項讓使用者隱藏功能表的快捷方式,以節省功能表空間,或隱藏要顯示的快速鍵。

適用於

另請參閱