KeyEventArgs.Control 속성

정의

Ctrl 키를 눌렀는지 여부를 나타내는 값을 가져옵니다.

public:
 property bool Control { bool get(); };
public bool Control { get; }
member this.Control : bool
Public ReadOnly Property Control As Boolean

속성 값

Ctrl 키를 눌렀으면 true이고, 누르지 않았으면 false입니다.

예제

다음 코드 예제를 사용 하는 방법에 설명 합니다 KeyDown 이벤트는 Help 팝업 스타일 애플리케이션의 사용자에 게 도움말을 표시 하는 클래스입니다. 이 예제에서는 이벤트 처리기 메서드에 전달된 속성을 사용하여 KeyEventArgs 한정자 키를 사용하여 F1 키를 누르는 모든 변형을 필터링합니다. 사용자가 키보드 한정자를 포함하는 F1의 변형을 누르면 클래스는 Help 컨트롤 근처에 있는 것과 유사한 ToolTip팝업 창을 표시합니다. 사용자가 ALT+F2를 누르면 추가 정보와 함께 다른 도움말 팝업이 표시됩니다.

   // This example demonstrates how to use the KeyDown event with the Help class to display
   // pop-up style help to the user of the application. The example filters for all variations
   // of pressing the F1 key with a modifier key by using the KeyEventArgs properties passed
   // to the event handling method.
   // When the user presses any variation of F1 that includes any keyboard modifier, the Help
   // class displays a pop-up window, similar to a ToolTip, near the control. If the user presses
   // ALT + F2, a different Help pop-up is displayed with additional information. This example assumes
   // that a tTextBox control, named textBox1, has been added to the form and its KeyDown
   // event has been contected to this event handling method.
private:
   void textBox1_KeyDown( Object^ /*sender*/, System::Windows::Forms::KeyEventArgs^ e )
   {
      // Determine whether the key entered is the F1 key. If it is, display Help.
      if ( e->KeyCode == Keys::F1 && (e->Alt || e->Control || e->Shift) )
      {
         
         // Display a pop-up Help topic to assist the user.
         Help::ShowPopup( textBox1, "Enter your name.", Point(textBox1->Bottom,textBox1->Right) );
      }
      else
      if ( e->KeyCode == Keys::F2 && e->Modifiers == Keys::Alt )
      {
         // Display a pop-up Help topic to provide additional assistance to the user.
         Help::ShowPopup( textBox1, "Enter your first name followed by your last name. Middle name is optional.",
            Point(textBox1->Top,this->textBox1->Left) );
      }
   }
private void textBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
    // Determine whether the key entered is the F1 key. If it is, display Help.
    if(e.KeyCode == Keys.F1 && (e.Alt || e.Control || e.Shift))
    {
        // Display a pop-up Help topic to assist the user.
        Help.ShowPopup(textBox1, "Enter your name.", new Point(textBox1.Bottom, textBox1.Right));
    }
    else if(e.KeyCode == Keys.F2 && e.Modifiers == Keys.Alt)
    {
        // Display a pop-up Help topic to provide additional assistance to the user.
        Help.ShowPopup(textBox1, "Enter your first name followed by your last name. Middle name is optional.",
            new Point(textBox1.Top, this.textBox1.Left));
    }
}
Private Sub textBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles textBox1.KeyDown
    ' Determine whether the key entered is the F1 key. If it is, display Help.
    If e.KeyCode = Keys.F1 AndAlso (e.Alt OrElse e.Control OrElse e.Shift) Then
        ' Display a pop-up Help topic to assist the user.
        Help.ShowPopup(textBox1, "Enter your name.", New Point(textBox1.Bottom, textBox1.Right))
    ElseIf e.KeyCode = Keys.F2 AndAlso e.Modifiers = Keys.Alt Then
        ' Display a pop-up Help topic to provide additional assistance to the user.
        Help.ShowPopup(textBox1, "Enter your first name followed by your last name. Middle name is optional.", _
             New Point(textBox1.Top, Me.textBox1.Left))
    End If
End Sub

적용 대상

추가 정보