StringFormat.HotkeyPrefix 속성

정의

StringFormat 개체의 HotkeyPrefix 개체를 가져오거나 설정합니다.

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 개체입니다. 기본값은 None입니다.

예제

다음 코드 예제를 사용 하 여 바로 가기 키를 설정 하는 방법을 보여 주세요는 HotkeyPrefix 속성입니다. 또한 메서드를 사용하는 방법을 보여 줍니다 FromSystemColor . 이 예제를 실행하려면 코드를 양식에 붙여넣고 양식의 Paint 이벤트를 처리하고 다음 메서드를 호출하여 e를 로 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 키와 같은 다른 키와 결합됨)입니다.

적용 대상