By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,890 Members | 1,097 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,890 IT Pros & Developers. It's quick & easy.

invok a button click

P: n/a
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

Nov 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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

"touf" <to******@hotmail.com> wrote in message
news:Oz*************@tk2msftngp13.phx.gbl...
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

Nov 20 '05 #2

P: n/a
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

"Jerry" <Je*********@yahoo.com> wrote in message
news:Os**************@TK2MSFTNGP10.phx.gbl...
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

"touf" <to******@hotmail.com> wrote in message
news:Oz*************@tk2msftngp13.phx.gbl...
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


Nov 20 '05 #3

P: n/a
"Christian Blackburn" <Christian@Damn@Sp**@Hotmail.com> schrieb
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).
--
Armin

Nov 20 '05 #4

P: n/a
Hello,

"touf" <to******@hotmail.com> schrieb:
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.

--
Herfried K. Wagner
MVP VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.