Control.Click 이벤트

정의

컨트롤을 클릭하면 발생합니다.

public:
 event EventHandler ^ Click;
public event EventHandler Click;
public event EventHandler? Click;
member this.Click : EventHandler 
Public Custom Event Click As EventHandler 

이벤트 유형

예제

다음 코드 예제에서는 이벤트 처리기의 이벤트를 보여줍니다 Click .

   // This example uses the Parent property and the Find method of Control to set
   // properties on the parent control of a Button and its Form. The example assumes
   // that a Button control named button1 is located within a GroupBox control. The 
   // example also assumes that the Click event of the Button control is connected to
   // the event handler method defined in the example.
private:
   void button1_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {
      // Get the control the Button control is located in. In this case a GroupBox.
      Control^ control = button1->Parent;
      
      // Set the text and backcolor of the parent control.
      control->Text = "My Groupbox";
      control->BackColor = Color::Blue;
      
      // Get the form that the Button control is contained within.
      Form^ myForm = button1->FindForm();
      
      // Set the text and color of the form containing the Button.
      myForm->Text = "The Form of My Control";
      myForm->BackColor = Color::Red;
   }
// This example uses the Parent property and the Find method of Control to set
// properties on the parent control of a Button and its Form. The example assumes
// that a Button control named button1 is located within a GroupBox control. The 
// example also assumes that the Click event of the Button control is connected to
// the event handler method defined in the example.
private void button1_Click(object sender, System.EventArgs e)
{
   // Get the control the Button control is located in. In this case a GroupBox.
   Control control = button1.Parent;
   // Set the text and backcolor of the parent control.
   control.Text = "My Groupbox";
   control.BackColor = Color.Blue;
   // Get the form that the Button control is contained within.
   Form myForm = button1.FindForm();
   // Set the text and color of the form containing the Button.
   myForm.Text = "The Form of My Control";
   myForm.BackColor = Color.Red;
}
' This example uses the Parent property and the Find method of Control to set
' properties on the parent control of a Button and its Form. The example assumes
' that a Button control named button1 is located within a GroupBox control. The 
' example also assumes that the Click event of the Button control is connected to
' the event handler method defined in the example.
Private Sub button1_Click(sender As Object, e As System.EventArgs) Handles button1.Click
   ' Get the control the Button control is located in. In this case a GroupBox.
   Dim control As Control = button1.Parent
   ' Set the text and backcolor of the parent control.
   control.Text = "My Groupbox"
   control.BackColor = Color.Blue
   ' Get the form that the Button control is contained within.
   Dim myForm As Form = button1.FindForm()
   ' Set the text and color of the form containing the Button.
   myForm.Text = "The Form of My Control"
   myForm.BackColor = Color.Red
End Sub

설명

이벤트는 Click 이벤트 처리기에 를 EventArgs 전달하므로 클릭이 발생했음을 나타냅니다. 보다 구체적인 마우스 정보 (단추 클릭 횟수, 휠이 회전 또는 위치)에 필요한 경우 사용 된 MouseClick 이벤트입니다. 그러나는 MouseClick 클릭 이외에 ENTER 키를 누르는 등의 마우스 작업으로 발생 하는 경우 이벤트를 발생 하지 것입니다.

두 번 클릭은 운영 체제의 마우스 설정에 따라 결정 됩니다. 천천히 두 번 클릭하는 것이 아닌 두 번 클릭(double-click)으로 간주될 수 있도록 마우스 단추 클릭 간격을 설정할 수 있습니다. Click 이벤트는 컨트롤을 두 번 클릭할 때마다 발생합니다. 예를 들어 의 및 DoubleClick 이벤트에 ClickForm대한 Click 이벤트 처리기가 있는 경우 폼을 두 번 클릭하고 두 메서드를 모두 호출할 때 및 DoubleClick 이벤트가 발생합니다. 컨트롤을 두 번 클릭하고 해당 컨트롤이 이벤트를 Click 지원하지 DoubleClick 않는 경우 이벤트가 두 번 발생할 수 있습니다.

이 이벤트를 발생하려면 값을 ControlStylestrue 로 설정 StandardClick 해야 합니다.

참고

컬렉션Click에 , MouseLeaveMouseEnterMouseUpMouseHoverMouseDownDoubleClickMouseMove가 하나 TabPage 이상 없는 한 클래스에 TabControl.TabPages 대해 TabControl 다음 이벤트가 발생하지 않습니다. 컬렉션에 하나 TabPage 이상이 있고 사용자가 탭 컨트롤의 머리글(이름이 표시되는 위치 TabPage )과 상호 작용하는 경우 는 TabControl 적절한 이벤트를 발생합니다. 그러나 사용자 상호 작용이 탭 페이지의 클라이언트 영역 내에 있는 경우 는 TabPage 적절한 이벤트를 발생합니다.

이벤트 처리에 대한 자세한 내용은 이벤트 처리 및 발생 을 참조하십시오.

상속자에 대한 참고 사항

표준 Windows Forms 컨트롤에서 상속하고 의 ControlStylestrue 또는 StandardDoubleClick 값을 변경 StandardClick 하면 예기치 않은 동작이 발생하거나 컨트롤이 또는 DoubleClick 이벤트를 지원하지 Click 않는 경우 전혀 영향을 주지 않을 수 있습니다.

다음 표에서는 지정된 마우스 동작에 대한 응답으로 발생하는 이벤트(Click또는 DoubleClick)와 Windows Forms 컨트롤을 나열합니다.

제어 마우스 왼쪽 클릭 마우스 왼쪽 두 번 클릭 마우스 오른쪽 단추 클릭 마우스 오른쪽 단추 두 번 클릭 마우스 가운데 클릭 마우스 가운데 두 번 클릭 XButton1 마우스 클릭 XButton1 마우스 Double-Click XButton2 마우스 클릭 XButton2 마우스 Double-Click
MonthCalendar, DateTimePicker, HScrollBar, VScrollBar 없음 없음 없음 없음 없음 없음 없음 없음 없음 없음
Button, CheckBox, RichTextBox, RadioButton 클릭 클릭, 클릭 없음 없음 없음 없음 없음 없음 없음 없음
ListBox, CheckedListBox, ComboBox 클릭 클릭, DoubleClick 없음 없음 없음 없음 없음 없음 없음 없음
TextBox, DomainUpDown, NumericUpDown 클릭 클릭, DoubleClick 없음 없음 없음 없음 없음 없음 없음 없음
* TreeView, * ListView 클릭 클릭, DoubleClick 클릭 클릭, DoubleClick 없음 없음 없음 없음 없음 없음
ProgressBar, TrackBar 클릭 클릭, 클릭 클릭 클릭, 클릭 클릭 클릭, 클릭 클릭 클릭, 클릭 클릭 클릭, 클릭
Form, DataGrid, Label, LinkLabel, Panel, GroupBox, PictureBox, Splitter, StatusBar, ToolBar, TabPage, ** TabControl 클릭 클릭, DoubleClick 클릭 클릭, DoubleClick 클릭 클릭, DoubleClick 클릭 클릭, DoubleClick 클릭 클릭, DoubleClick

* 마우스 포인터는 자식 개체(TreeNode 또는 ListViewItem)에 있어야 합니다.

** 컬렉션 TabControlTabPages 가 하나 TabPage 이상 있어야 합니다.

적용 대상

추가 정보