invok a button click

  • Thread starter Thread starter touf
  • Start date Start date
T

touf

Hi,
How can I invoke by code a buttoin click event.

I like to call the function that handles the button click.
I'\ve seen the command RAISEEVENT but I didn't know how to use it ion this
case.
Thanks
 
There are a number of ways to do this.
Most likely the most straight forward way would be to have a subroutine
which performs the desired code you wish to run. Then, you can call this
subroutine either by calling it from the button event or from your other
code.
You dont want to raise the button event, you want to run the code which the
button causes.

Regards
 
Hi Touf,
For the most part I've gotta agree with Jerry. Unless you are testing your
button routine what he recommended is ideal. However since you asked I'll go
ahead and tell ya:
If I wanted to click a menu item from a button I'd just put the following
code in a button
mnuOpenGame_Click(sender, e)
so to simulate a button click it's almost identical
btnOpen_Click(sender, e).
Cheers,
Christian Blackburn
 
Christian Blackburn said:
Hi Touf,
For the most part I've gotta agree with Jerry. Unless you are
testing your button routine what he recommended is ideal. However
since you asked I'll go ahead and tell ya:
If I wanted to click a menu item from a button I'd just put the
following code in a button
mnuOpenGame_Click(sender, e)
so to simulate a button click it's almost identical
btnOpen_Click(sender, e).

Apart from the fact - that you are of course aware of - that's bad design
because the menu has not been clicked. Further more, a menu has a
PerformClick method (mnuOpenGame.PerformClick).
 
Hello,

touf said:
How can I invoke by code a buttoin click event.

I like to call the function that handles the button click.
I'\ve seen the command RAISEEVENT but I didn't know
how to use it ion this

'RaiseEvent' doesn't work here. Call the button's 'PerformClick' method.
 
Back
Top