MenuItem.ShowShortcut 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
會取得或設定一個值,指示與選單項目相關的快捷鍵是否會顯示在選單項目說明旁邊。
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
屬性值
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
備註
你可以利用這個功能,讓使用者選擇隱藏選單中的捷徑,以節省選單空間,或隱藏快捷鍵不被顯示。