Aracılığıyla paylaş


StringFormat.HotkeyPrefix Özellik

Tanım

Bu StringFormat nesnenin HotkeyPrefix nesnesini alır veya ayarlar.

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

Özellik Değeri

HotkeyPrefix Bu StringFormat nesnenin nesnesi varsayılan değerdirNone.

Örnekler

Aşağıdaki kod örneğinde özelliğini kullanarak klavye kısayolunun nasıl ayarlanacağı gösterilmektedir HotkeyPrefix . Ayrıca yönteminin nasıl kullanılacağını FromSystemColor da gösterir. Bu örneği çalıştırmak için kodu bir forma yapıştırın, formun Paint olayını işleyip e'yi olarak PaintEventArgsgeçirerek aşağıdaki yöntemi çağırın.

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

Açıklamalar

Grafik kullanıcı arabiriminde kısayol tuşu, sözcüğün temsil ettiği işlevselliği etkinleştirmek için klavyede basabileceğiniz bir sözcüğün altı çizili harftir (genellikle Alt tuşu gibi başka bir tuşla birlikte).

Şunlara uygulanır