Freigeben über


MenuItem.Shortcut-Eigenschaft

Ruft einen Wert ab, der die dem Menüelement zugeordnete Tastenkombination angibt, oder legt diesen fest.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
<LocalizableAttribute(True)> _
Public Property Shortcut As Shortcut
'Usage
Dim instance As MenuItem
Dim value As Shortcut

value = instance.Shortcut

instance.Shortcut = value
[LocalizableAttribute(true)] 
public Shortcut Shortcut { get; set; }
[LocalizableAttribute(true)] 
public:
property Shortcut Shortcut {
    Shortcut get ();
    void set (Shortcut value);
}
/** @property */
public Shortcut get_Shortcut ()

/** @property */
public void set_Shortcut (Shortcut value)
public function get Shortcut () : Shortcut

public function set Shortcut (value : Shortcut)

Eigenschaftenwert

Einer der Shortcut-Werte. Der Standardwert ist Shortcut.None.

Ausnahmen

Ausnahmetyp Bedingung

InvalidEnumArgumentException

Der zugewiesene Wert ist keiner der Shortcut-Werte.

Hinweise

Tastenkombinationen stellen eine Methode zum Aktivieren häufig verwendeter Menüelemente im Menüsystem bereit. Außerdem ermöglichen sie einen Tastaturzugriff auf die Anwendung für Benutzer, die nicht über eine Maus oder ein anderes Zeigegerät verfügen.

Beispiel

Im folgenden Codebeispiel werden ein Menüelement erstellt, die Beschriftung festgelegt, eine Tastenkombination zugewiesen, das Menüelement sichtbar gemacht und die Tastenkombination für das Menüelement angezeigt. Bei diesem Beispiel ist es erforderlich, dass zuvor ein MenuItem mit dem Namen menuItem1 erstellt wurde.

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
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 void SetupMyMenuItem()
{
    // Set the caption for the menu item.
    menuItem1.set_Text("&New");

    // Assign a shortcut key.
    menuItem1.set_Shortcut(Shortcut.CtrlN);

    // Make the menu item visible.
    menuItem1.set_Visible(true);

    // Display the shortcut key combination.
    menuItem1.set_ShowShortcut(true);
} //SetupMyMenuItem

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

MenuItem-Klasse
MenuItem-Member
System.Windows.Forms-Namespace
Shortcut