Freigeben über


StringFormat.HotkeyPrefix-Eigenschaft

Ruft das HotkeyPrefix-Objekt für dieses StringFormat-Objekt ab oder legt dieses fest.

Namespace: System.Drawing
Assembly: System.Drawing (in system.drawing.dll)

Syntax

'Declaration
Public Property HotkeyPrefix As HotkeyPrefix
'Usage
Dim instance As StringFormat
Dim value As HotkeyPrefix

value = instance.HotkeyPrefix

instance.HotkeyPrefix = value
public HotkeyPrefix HotkeyPrefix { get; set; }
public:
property HotkeyPrefix HotkeyPrefix {
    HotkeyPrefix get ();
    void set (HotkeyPrefix value);
}
/** @property */
public HotkeyPrefix get_HotkeyPrefix ()

/** @property */
public void set_HotkeyPrefix (HotkeyPrefix value)
public function get HotkeyPrefix () : HotkeyPrefix

public function set HotkeyPrefix (value : HotkeyPrefix)

Eigenschaftenwert

Das HotkeyPrefix-Objekt für dieses StringFormat-Objekt.

Hinweise

In einer grafischen Benutzeroberfläche entspricht eine Zugriffstaste dem unterstrichenen Buchstaben in einem Wort, üblicherweise in Verbindung mit einer anderen Taste, z. B. ALT. Mit der Zugriffstaste kann die von dem Wort dargestellte Funktion aktiviert werden.

Beispiel

Im folgenden Codebeispiel wird veranschaulicht, wie mit der HotkeyPrefix-Eigenschaft eine Tastenkombination festgelegt wird. Darüber hinaus wird die Verwendung der FromSystemColor-Methode veranschaulicht. Fügen Sie zum Ausführen dieses Beispiels den Code in ein Formular ein, behandeln Sie das Paint-Ereignis des Formulars, und rufen Sie die folgende Methode auf, wobei Sie e als PaintEventArgs übergeben.

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
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:
   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.set_HotkeyPrefix(System.Drawing.Text.HotkeyPrefix.Show);

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

    e.get_Graphics().DrawString(text, this.get_Font(), theBrush, 30, 40, 
        format);
} //ShowHotKey

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

StringFormat-Klasse
StringFormat-Member
System.Drawing-Namespace