Button.PerformClick Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Gera um Click evento para um botão.
public:
virtual void PerformClick();
public void PerformClick();
abstract member PerformClick : unit -> unit
override this.PerformClick : unit -> unit
Public Sub PerformClick ()
Implementações
Exemplos
O seguinte exemplo de código gera um Click evento de a Button em eventos alternados Click de outro botão. Este código assume que dois Button controlos foram instanciados num formulário e que uma variável membro nomeada myVar foi declarada como um inteiro assinado de 32 bits dentro da classe.
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
Observações
Este método pode ser chamado para elevar o Click evento.