MenuItem.Shortcut 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定一個值,指示與選單項目相關的快捷鍵。
public:
property System::Windows::Forms::Shortcut Shortcut { System::Windows::Forms::Shortcut get(); void set(System::Windows::Forms::Shortcut value); };
public System.Windows.Forms.Shortcut Shortcut { get; set; }
member this.Shortcut : System.Windows.Forms.Shortcut with get, set
Public Property Shortcut As Shortcut
屬性值
這是其中一項 Shortcut 價值。 預設值為 Shortcut.None。
例外狀況
分配的數值並非其中之一。Shortcut
範例
以下程式碼範例會建立選單項目、設定說明文字、指派快捷鍵、讓選單項目可見,並顯示該選單項目的快捷鍵顯示。 該範例要求已建立一個 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
備註
捷徑鍵提供使用者啟用菜單系統中常用選單項目的方法,並為無法使用滑鼠或其他指標裝置的使用者提供鍵盤存取應用程式的功能。