Generates a System.WinForms.Control.Click event for a button.
[Visual Basic] Overridable Public Sub PerformClick() [C#] public virtual void PerformClick(); [C++] public: virtual void PerformClick(); [JScript] public function PerformClick();
This method is called when the user presses the ENTER key(if the button has focus or is the default button and no other button has focus) or the ESC key(if the button is the cancel button).
The following example generates a System.WinForms.Control.Click event of a Button on alternating calls of this sub procedure. This code assumes that two Button controls and a Label have been instantiated on a form.
[Visual Basic]
Private Sub MyVar() Static Dim myVar As Integer ' If myVar is an even number, click Button2. If myVar Mod 2 = 0 Then Button2.PerformClick Label1.Text = "Button1 and Button2 were clicked" Else ' Display the status of Button2's Click event. Me.Label1.Text = "Button2 was NOT clicked." End If ' Increment myVar by one. myVar = myVar + 1 End Sub