Freigeben über


StringFormat.HotkeyPrefix Eigenschaft

Definition

Dient zum Abrufen oder Festlegen des HotkeyPrefix Objekts für dieses StringFormat Objekt.

public:
 property System::Drawing::Text::HotkeyPrefix HotkeyPrefix { System::Drawing::Text::HotkeyPrefix get(); void set(System::Drawing::Text::HotkeyPrefix value); };
public System.Drawing.Text.HotkeyPrefix HotkeyPrefix { get; set; }
member this.HotkeyPrefix : System.Drawing.Text.HotkeyPrefix with get, set
Public Property HotkeyPrefix As HotkeyPrefix

Eigenschaftswert

Das HotkeyPrefix Objekt für dieses StringFormat Objekt, der Standardwert ist None.

Beispiele

Das folgende Codebeispiel zeigt, wie Sie eine Tastenkombination mithilfe der HotkeyPrefix Eigenschaft festlegen. Außerdem wird die Verwendung der FromSystemColor Methode veranschaulicht. Zum Ausführen dieses Beispiels fügen Sie den Code in ein Formular ein, behandeln das Ereignis des Formulars Paint und rufen die folgende Methode auf, und übergeben Sie e als PaintEventArgs.

private:
   void ShowHotKey( PaintEventArgs^ e )
   {
      // Declare the string with a keyboard shortcut.
      String^ text = "&Click Here";

      // Declare a new StringFormat.
      StringFormat^ format = gcnew StringFormat;

      // Set the HotkeyPrefix property.
      format->HotkeyPrefix = System::Drawing::Text::HotkeyPrefix::Show;

      // Draw the string.
      Brush^ theBrush = SystemBrushes::FromSystemColor( SystemColors::Highlight );
      e->Graphics->DrawString( text, this->Font, theBrush, 30, 40, format );
   }
private void ShowHotKey(PaintEventArgs e)
{

    // Declare the string with a keyboard shortcut.
    string text = "&Click Here";

    // Declare a new StringFormat.
    StringFormat format = new StringFormat();

    // Set the HotkeyPrefix property.
    format.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show;

    // Draw the string.
    Brush theBrush = 
        SystemBrushes.FromSystemColor(SystemColors.Highlight);

    e.Graphics.DrawString(text, this.Font, theBrush, 30, 40, format);
}
Private Sub ShowHotKey(ByVal e As PaintEventArgs)

    ' Declare the string with keyboard shortcut.
    Dim text As String = "&Click Here"

    ' Declare a new StringFormat.
    Dim format As New StringFormat

    ' Set the HotkeyPrefix property.
    format.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show

    ' Draw the string.
    Dim theBrush As Brush = _
        SystemBrushes.FromSystemColor(SystemColors.Highlight)
    e.Graphics.DrawString(text, Me.Font, theBrush, 30, 40, format)
End Sub

Hinweise

In einer grafischen Benutzeroberfläche ist eine Abkürzungstaste der unterstrichene Buchstabe in einem Wort (in der Regel in Kombination mit einer anderen Taste, z. B. der ALT-TASTE), die Sie auf der Tastatur drücken können, um die Funktionalität zu aktivieren, die das Wort darstellt.

Gilt für: