Control.Click イベント
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

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)

Click イベントは EventArgs をそのイベント ハンドラに渡します。これは、クリックが発生したことを示すにすぎません。マウスに関するより詳細な情報、たとえば、ボタン、クリック回数、ホイール回転、位置などの情報が必要な場合は、MouseClick イベントを使用します。ただし、Enter キーを押すなど、マウスのクリック以外のアクションによってクリックが行われた場合、MouseClick イベントは発生しません。
ユーザーのオペレーティング システムのマウス設定に応じて、ダブルクリックが決定されます。ユーザーは、2 回のクリックではなくダブルクリックと見なされるマウス ボタンのクリック間隔を設定できます。Click イベントは、コントロールがダブルクリックされるたびに発生します。たとえば、Form の Click イベントおよび DoubleClick イベントに対してそれぞれイベント ハンドラがある場合は、フォームがダブルクリックされ両方のメソッドが呼び出されると Click イベントと DoubleClick イベントが発生します。ダブルクリックされたコントロールが DoubleClick イベントをサポートしていない場合は、Click イベントが 2 回発生することがあります。
このイベントを発生させるには、ControlStyles の StandardClick 値を true に設定する必要があります。
![]() |
---|
Click、DoubleClick、MouseDown、MouseUp、MouseHover、MouseEnter、MouseLeave、MouseMove の各イベントは、TabControl.TabPages コレクションに 1 つ以上の TabPage が存在しない限り、TabControl クラスで生成されません。コレクションに 1 つ以上の TabPage があり、ユーザーがタブ コントロールのヘッダー (TabPage の名前が表示される場所) と対話すると、TabControl が適切なイベントを発生させます。ただし、ユーザーとの対話がタブ ページのクライアント領域内の場合、TabPage は該当するイベントを発生させます。 |
イベント処理の詳細については、「イベントの利用」を参照してください。
継承時の注意 標準の Windows フォーム コントロールから継承し、ControlStyles の StandardClick 値または StandardDoubleClick 値を true に変更すると、コントロールが Click イベントまたは DoubleClick イベントをサポートしていない場合は、予測できない動作が行われたり、何の効果も得られなかったりします。 Windows フォーム コントロールと、指定したマウス アクションに対して発生するイベント (Click または DoubleClick) の一覧を次に示します。 MonthCalendar, DateTimePicker, HScrollBar, VScrollBar | なし | なし | なし | なし | なし | なし | なし | なし | なし | なし |
RichTextBox, | なし | なし | なし | なし | なし | なし | なし | なし | ||
CheckedListBox, | なし | なし | なし | なし | なし | なし | なし | なし | ||
DomainUpDown, NumericUpDown | なし | なし | なし | なし | なし | なし | なし | なし | ||
* TreeView, * ListView | なし | なし | なし | なし | なし | なし | ||||
TrackBar | ||||||||||
Form, DataGrid, LinkLabel, GroupBox, PictureBox, TabPage, ** TabControl |

イベント ハンドラの 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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Control クラス
Control メンバ
System.Windows.Forms 名前空間
OnClick
StandardClick
MouseClick
DoubleClick
MouseDoubleClick
Weblioに収録されているすべての辞書からControl.Click イベントを検索する場合は、下記のリンクをクリックしてください。

- Control.Click イベントのページへのリンク