Control.Click 이벤트
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
컨트롤을 클릭할 때 발생합니다.
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 키를 누르는 것과 같이 마우스 이외의 동작으로 인해 클릭이 발생하는 경우에는 이벤트가 발생하지 않습니다.
두 번 클릭은 사용자 운영 체제의 마우스 설정에 따라 결정됩니다. 사용자는 두 번의 클릭이 아닌 두 번 클릭으로 간주되어야 하는 마우스 단추 클릭 사이의 시간을 설정할 수 있습니다. 컨트롤 Click 을 두 번 클릭할 때마다 이벤트가 발생합니다. 예를 들어, 이벤트의 이벤트 처리기와 이벤트 ClickDoubleClickForm 처리기가 ClickDoubleClick 있는 경우 폼을 두 번 클릭하고 두 메서드를 모두 호출할 때 이벤트와 이벤트가 발생합니다. 컨트롤을 두 번 클릭하고 해당 컨트롤이 이벤트를 DoubleClick 지원하지 Click 않는 경우 이벤트가 두 번 발생할 수 있습니다.
이 이벤트가 발생하려면 StandardClick 값을 ControlStyles 설정 true 해야 합니다.
메모
컬렉션에 하나 이상의 TabControlTabPage 이벤트가 없으면 클래스에 TabControl.TabPages 대해 다음 이벤트가 발생하지 않습니다. ClickDoubleClickMouseDownMouseUpMouseHoverMouseEnterMouseLeaveMouseMove 컬렉션에 하나 TabPage 이상이 있고 사용자가 탭 컨트롤의 머리글(이름이 표시되는 위치 TabPage ) TabControl 과 상호 작용하는 경우 적절한 이벤트가 발생합니다. 그러나 사용자 상호 작용이 탭 페이지의 TabPage 클라이언트 영역 내에 있는 경우 적절한 이벤트가 발생합니다.
이벤트 처리에 대한 자세한 내용은 이벤트 처리 및 발생시키기를 참조하십시오.
상속자에 대한 참고 사항
표준 Windows Forms 컨트롤에서 상속하고 StandardClickStandardDoubleClick 또는 ControlStyles 값을 true 변경하면 예기치 않은 동작이 발생하거나 컨트롤이 Click 또는 DoubleClick 이벤트를 지원하지 않는 경우 전혀 영향을 주지 않을 수 있습니다.
다음 표에서는 Windows Forms 컨트롤과 지정된 마우스 동작에 대한 응답으로 발생하는 이벤트(Click 또는 DoubleClick)를 나열합니다.
| 제어 | 마우스 왼쪽 단추 클릭 | 마우스 왼쪽 두 번 클릭 | 마우스 오른쪽 단추 클릭 | 마우스 오른쪽 단추로 두 번 클릭 | 마우스 가운데 클릭 | 마우스 가운데 두 번 클릭 | XButton1 마우스 클릭 | XButton1 마우스 Double-Click | XButton2 마우스 클릭 | XButton2 마우스 Double-Click |
|---|---|---|---|---|---|---|---|---|---|---|
| MonthCalendar, DateTimePicker, , HScrollBar, VScrollBar | 없음 | 없음 | 없음 | 없음 | 없음 | 없음 | 없음 | 없음 | 없음 | 없음 |
| Button, CheckBox, , RichTextBox, RadioButton | 클릭 | 클릭, 클릭 | 없음 | 없음 | 없음 | 없음 | 없음 | 없음 | 없음 | 없음 |
| ListBox, , CheckedListBoxComboBox | 클릭 | 클릭, 더블클릭 | 없음 | 없음 | 없음 | 없음 | 없음 | 없음 | 없음 | 없음 |
| TextBox, , DomainUpDownNumericUpDown | 클릭 | 클릭, 더블클릭 | 없음 | 없음 | 없음 | 없음 | 없음 | 없음 | 없음 | 없음 |
| * TreeView, * ListView | 클릭 | 클릭, 더블클릭 | 클릭 | 클릭, 더블클릭 | 없음 | 없음 | 없음 | 없음 | 없음 | 없음 |
| ProgressBar, TrackBar | 클릭 | 클릭, 클릭 | 클릭 | 클릭, 클릭 | 클릭 | 클릭, 클릭 | 클릭 | 클릭, 클릭 | 클릭 | 클릭, 클릭 |
| Form, DataGrid,Label, LinkLabel, Panel, GroupBox, PictureBox, Splitter, StatusBarToolBar, TabPage**TabControl | 클릭 | 클릭, 더블클릭 | 클릭 | 클릭, 더블클릭 | 클릭 | 클릭, 더블클릭 | 클릭 | 클릭, 더블클릭 | 클릭 | 클릭, 더블클릭 |
* 마우스 포인터는 자식 개체(TreeNode 또는 ListViewItem)에 있어야 합니다.
TabControl** 컬렉션에 TabPage 하나 TabPages 이상이 있어야 합니다.