Button.PerformClick 메서드

정의

단추에 대해 Click 이벤트를 생성합니다.

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

구현

예제

다음 코드 예제에서는 Click 다른 단추의 Button 이벤트를 번갈아가며 Click 의 이벤트를 생성합니다. 이 코드에서는 두 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++;
   }
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

설명

이벤트를 발생 하려면이 메서드를 호출할 수 있습니다 Click .

적용 대상

추가 정보