Button.PerformClick Button.PerformClick Button.PerformClick Button.PerformClick Method

정의

단추에 대해 Click 이벤트를 생성합니다.Generates a Click event for a button.

public:
 virtual void PerformClick();
public void PerformClick ();
abstract member PerformClick : unit -> unit
override this.PerformClick : unit -> unit
Public Sub PerformClick ()

구현

예제

다음 코드 예제에서는 생성을 Click 의 이벤트를 Button 에서 교대로 반복 되는 Click 다른 단추의 이벤트입니다.The following code example generates a Click event of a Button on alternating Click events of another button. 이 코드에서는 두 개의 Button 폼에서 인스턴스화된 컨트롤 및 멤버 변수 명명 된 myVar 클래스 내에서 32 비트 부호 있는 정수로 선언 합니다.This code assumes that two Button controls have been instantiated on a form and that a member variable named myVar has been declared as a 32-bit signed integer within the class.

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++;
   }
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;
 }
 
Private Sub button1_Click(sender As Object, e As EventArgs)
    ' If myVar is an even number, click Button2.
    If myVar Mod 2 = 0 Then
        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")
    End If
    ' Increment myVar.   
    myVar = myVar + 1
End Sub 'button1_Click

설명

발생 시키려면이 메서드를 호출할 수는 Click 이벤트입니다.This method can be called to raise the Click event.

적용 대상

추가 정보