다음을 통해 공유


Control.Click 이벤트

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

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
Public Event Click As EventHandler
‘사용 방법
Dim instance As Control
Dim handler As EventHandler

AddHandler instance.Click, handler
public event EventHandler Click
public:
event EventHandler^ Click {
    void add (EventHandler^ value);
    void remove (EventHandler^ value);
}
/** @event */
public void add_Click (EventHandler value)

/** @event */
public void remove_Click (EventHandler value)
JScript에서는 이벤트를 사용할 수 있지만 새로 선언할 수는 없습니다.

설명

Click 이벤트는 해당 이벤트 처리기에 EventArgs를 전달하여, 클릭이 발생되었다는 사실만 나타냅니다. 특정 마우스 정보(단추, 클릭 횟수, 휠 회전 또는 위치)가 추가로 필요하면 MouseClick 이벤트를 사용합니다. 그러나 MouseClick 이벤트는 Enter 키 누르기와 같이 마우스 작업 이외의 작업으로 클릭된 경우에는 발생하지 않습니다.

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

이 이벤트를 발생시키려면 ControlStylesStandardClick 값을 true로 설정해야 합니다.

참고

TabControl.TabPages 컬렉션에 TabPage가 하나 이상 있어야만 TabControl 클래스에 대해 Click, DoubleClick, MouseDown, MouseUp, MouseHover, MouseEnter, MouseLeaveMouseMove 이벤트가 발생합니다. 컬렉션에 TabPage가 하나 이상 있는 경우 사용자가 TabPage 이름이 나타나는 탭 컨트롤의 머리글과 상호 작용하면 TabControl에서 해당 이벤트를 발생시킵니다. 그러나 사용자 상호 작용이 탭 페이지의 클라이언트 영역 내에 있는 경우 TabPage는 해당 이벤트를 발생시킵니다.

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

상속자 참고 사항 표준 Windows Forms 컨트롤에서 상속하고 ControlStylesStandardClick 또는 StandardDoubleClick 값을 true로 변경한 경우 해당 컨트롤이 Click 또는 DoubleClick 이벤트를 지원하지 않으면 예상치 못한 동작이 발생하거나 아무런 결과도 나타나지 않을 수 있습니다. 다음 표에서는 Windows Forms 컨트롤과 지정된 마우스 동작에 대한 응답으로 발생하는 이벤트(Click 또는 DoubleClick)를 보여 줍니다.

컨트롤

마우스 왼쪽 단추 클릭

마우스 왼쪽 단추 두 번 클릭

마우스 오른쪽 단추 클릭

마우스 오른쪽 단추 두 번 클릭

마우스 가운데 단추 클릭

마우스 가운데 단추 두 번 클릭

XButton1 마우스 클릭

XButton1 마우스 두 번 클릭

XButton2 마우스 클릭

Xbutton2 마우스 두 번 클릭

MonthCalendar,

DateTimePicker,

HScrollBar,

VScrollBar

없음

없음

없음

없음

없음

없음

없음

없음

없음

없음

Button,

CheckBox,

RichTextBox,

RadioButton

클릭

클릭, 클릭

없음

없음

없음

없음

없음

없음

없음

없음

ListBox,

CheckedListBox,

ComboBox

클릭

클릭, 두 번 클릭

없음

없음

없음

없음

없음

없음

없음

없음

TextBox,

DomainUpDown,

NumericUpDown

클릭

클릭, 두 번 클릭

없음

없음

없음

없음

없음

없음

없음

없음

* TreeView,

* ListView

클릭

클릭, 두 번 클릭

클릭

클릭, 두 번 클릭

없음

없음

없음

없음

없음

없음

ProgressBar,

TrackBar

클릭

클릭, 클릭

클릭

클릭, 클릭

클릭

클릭, 클릭

클릭

클릭, 클릭

클릭

클릭, 클릭

Form,

DataGrid,

Label,

LinkLabel,

Panel,

GroupBox,

PictureBox,

Splitter,

StatusBar,

ToolBar,

TabPage,

** TabControl

클릭

클릭, 두 번 클릭

클릭

클릭, 두 번 클릭

클릭

클릭, 두 번 클릭

클릭

클릭, 두 번 클릭

클릭

클릭, 두 번 클릭

* 마우스 포인터가 자식 개체(TreeNode 또는 ListViewItem) 위에 있어야 합니다. ** TabControl의 해당 TabPages 컬렉션에는 하나 이상의 TabPage가 있어야 합니다.

예제

다음 코드 예제에서는 이벤트 처리기의 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 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
// 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 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.get_Parent();

    // Set the text and backcolor of the parent control.
    control.set_Text("My Groupbox");
    control.set_BackColor(Color.get_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.set_Text("The Form of My Control");
    myForm.set_BackColor(Color.get_Red());
} //button1_Click

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

Control 클래스
Control 멤버
System.Windows.Forms 네임스페이스
OnClick
StandardClick
MouseClick
DoubleClick
MouseDoubleClick