Call a button's code

  • Thread starter Thread starter Amjad
  • Start date Start date
A

Amjad

How can I execute the code of a button control when
another button is clicked?

Amjad
 
Just invoke the method that handles the click event of the other button:

Button1_Click(Button2, EventArgs.Empty)
 
Hi Amjad,

Quit simple

If you are in the clickeventButtonA

Then clickeventButtonB(sender, e)

That is all

Cor
 
* "Amjad said:
How can I execute the code of a button control when
another button is clicked?

\\\
btnFoo.PerformClick()
///
 
Just invoke the method that handles the click event of the other button:

Button1_Click(Button2, EventArgs.Empty)

Better would be Button1.PerformClick. Or better yet, move the code in
Button1's handler to a separate sub so you can call that from both places.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top