Control.Click イベントとは? わかりやすく解説

Control.Click イベント

コントロールクリックされたときに発生します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

解説解説

Click イベントは EventArgs をそのイベント ハンドラ渡します。これは、クリック発生したことを示すにすぎません。マウスに関するより詳細情報、たとえば、ボタンクリック回数ホイール回転位置などの情報必要な場合は、MouseClick イベント使用します。ただし、Enter キーを押すなど、マウスクリック以外のアクションによってクリックが行われた場合MouseClick イベント発生しません。

ユーザーオペレーティング システムマウス設定に応じてダブルクリック決定されます。ユーザーは、2 回のクリックではなくダブルクリック見なされるマウス ボタンクリック間隔設定できますClick イベントは、コントロールダブルクリックされるたびに発生します。たとえば、FormClick イベントおよび DoubleClick イベントに対してそれぞれイベント ハンドラがある場合は、フォームダブルクリックされ両方メソッド呼び出されるClick イベントDoubleClick イベント発生しますダブルクリックされたコントロールDoubleClick イベントサポートしてない場合は、Click イベントが 2 回発生することがあります

このイベント発生させるには、ControlStyles の StandardClick 値を true設定する必要があります

メモメモ

ClickDoubleClick、MouseDown、MouseUp、MouseHover、MouseEnter、MouseLeave、MouseMove の各イベントは、TabControl.TabPages コレクション1 つ上の TabPage が存在しない限り、TabControl クラス生成されません。コレクション1 つ上の TabPage があり、ユーザータブ コントロールヘッダー (TabPage の名前が表示される場所) と対話すると、TabControl適切なイベント発生させます。ただし、ユーザーとの対話タブ ページクライアント領域内の場合TabPage該当するイベント発生させます

イベント処理詳細については、「イベント利用」を参照してください

継承時の注意 標準Windows フォーム コントロールか継承しControlStylesStandardClick 値または StandardDoubleClick 値を true変更すると、コントロールClick イベントまたは DoubleClick イベントサポートしてない場合は、予測できない動作が行われたり、何の効果得られなかったりしますWindows フォーム コントロールと、指定したマウス アクションに対して発生するイベント (Click または DoubleClick) の一覧を次に示します

コントロール

マウス クリック

マウス ダブルクリック

マウス クリック

マウス ダブルクリック

中央マウス クリック

中央マウス ダブルクリック

XButton1 マウス クリック

XButton1 マウス ダブルクリック

XButton2 マウス クリック

XButton2 マウス ダブルクリック

MonthCalendar,

DateTimePicker,

HScrollBar,

VScrollBar

なし

なし

なし

なし

なし

なし

なし

なし

なし

なし

Button,

CheckBox,

RichTextBox,

RadioButton

Click

Click, Click

なし

なし

なし

なし

なし

なし

なし

なし

ListBox,

CheckedListBox,

ComboBox

Click

Click, DoubleClick

なし

なし

なし

なし

なし

なし

なし

なし

TextBox,

DomainUpDown,

NumericUpDown

Click

Click, DoubleClick

なし

なし

なし

なし

なし

なし

なし

なし

* TreeView,

* ListView

Click

Click, DoubleClick

Click

Click, DoubleClick

なし

なし

なし

なし

なし

なし

ProgressBar,

TrackBar

Click

Click, Click

Click

Click, Click

Click

Click, Click

Click

Click, Click

Click

Click, Click

Form,

DataGrid,

Label,

LinkLabel,

Panel,

GroupBox,

PictureBox,

Splitter,

StatusBar,

ToolBar,

TabPage,

** TabControl

Click

Click, DoubleClick

Click

Click, DoubleClick

Click

Click, DoubleClick

Click

Click, DoubleClick

Click

Click, DoubleClick

* マウス ポインタが子オブジェクト (TreeNode または ListViewItem) の上になければなりません。 ** TabControl には、TabPages コレクション内に少なくとも 1 つ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
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からControl.Click イベントを検索した結果を表示しています。
Weblioに収録されているすべての辞書からControl.Click イベントを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からControl.Click イベント を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Control.Click イベント」の関連用語

Control.Click イベントのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Control.Click イベントのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS