Click a button on the form via code?

  • Thread starter Thread starter vbMark
  • Start date Start date
V

vbMark

I want to call this function via code:


private void btnExit_Click(object sender, System.EventArgs e)
{
Close();
}


How do I do this?

Thanks!
 
From the form:

this.Invoke( new EventHandler(btnExit_Click), new object[]{this,
EventArgs.Empty});

Brendan
 
I forgot to mention, the code in my previous reply is for if you are making
that call from another thread and want the call to occur within the main
thread.

Otherwise, if both are the same thread, you can simply call the function
from within the class with:

btnExit_Click(this, EventArgs.Empty);

Brendan
 
Thank you. Your code works fine but did not solve my bigger problem
which I posted in another thread.
 

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