StringFormat.HotkeyPrefix StringFormat.HotkeyPrefix StringFormat.HotkeyPrefix StringFormat.HotkeyPrefix Property

定義

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

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

プロパティ値

この 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のイベントを処理して、次のメソッドPaintEventArgsを呼び出します。 e はとして渡されます。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.

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

注釈

グラフィカルユーザーインターフェイスでは、ホットキーは、単語が表す機能をアクティブにするためにキーボードで押すことができる、単語内の下線付きの文字 (通常は 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.

適用対象