StringFormat.HotkeyPrefix プロパティ


この HotkeyPrefix オブジェクトの StringFormat オブジェクトを取得または設定します。Gets or sets the HotkeyPrefix object for this StringFormat object.

 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



この StringFormat オブジェクトの HotkeyPrefix オブジェクト。既定値は、NoneThe HotkeyPrefix object for this StringFormat object, the default is None.

次のコード例は、プロパティを使用してキーボードショートカットを設定する方法を示して HotkeyPrefix います。The following code example shows how to set a keyboard shortcut using the HotkeyPrefix property. また、メソッドの使用方法も示し FromSystemColor ます。It also demonstrates how to use the FromSystemColor method. この例を実行するには、フォームにコードを貼り付け、フォームのイベントを処理 Paint して、次のメソッドを呼び出します。 e はとして渡さ PaintEventArgs れます。To run this example, paste the code into a form, handle the form's Paint event and call the following method, passing e as PaintEventArgs.

   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 = 

    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 = _
    e.Graphics.DrawString(text, Me.Font, theBrush, 30, 40, format)
End Sub


グラフィカルユーザーインターフェイスでは、ホットキーは、単語が表す機能をアクティブにするためにキーボードで押すことができる、単語内の下線付きの文字 (通常は Alt キーなどの別のキーと組み合わせたもの) です。In a graphical user interface, a hot key is the underlined letter in a word (usually combined with another key, such as the Alt key) that you can press on the keyboard to activate the functionality that the word represents.