この記事は翻訳者によって翻訳されたものです。 記事の文章にポインターを重ねると、原文のテキストが表示されます。 |
訳文
原文
|
Button.PerformClick メソッド
.NET Framework 4
ボタンの Click イベントを生成します。
アセンブリ: System.Windows.Forms (System.Windows.Forms.dll 内)
他のボタンの Click イベントが発生したときに、一回おきに Button の Click イベントを生成するコード例を次に示します。 このコードは、2 つの Button コントロールがフォーム上でインスタンス化され、myVar という名前のメンバー変数がクラス内の 32 ビット符号付き整数として宣言されていることを前提にしています。
private void button1_Click (Object sender, EventArgs e) { // If myVar is an even number, click Button2. if(myVar %2 == 0) { button2.PerformClick(); // Display the status of Button2's Click event. MessageBox.Show("button2 was clicked "); } else { // Display the status of Button2's Click event. MessageBox.Show("button2 was NOT clicked"); } // Increment myVar. myVar = myVar + 1; }
Windows 7, Windows Vista SP1 以降, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core はサポート対象外), Windows Server 2008 R2 (SP1 以降で Server Core をサポート), Windows Server 2003 SP2
.NET Framework では、各プラットフォームのすべてのバージョンはサポートしていません。 サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。