How can I call the Click even of a button from somewhere else in code?
Printable View
How can I call the Click even of a button from somewhere else in code?
vb Code:
button1.performclick
Thanks. Is it the same for other controls too, like the PictureBox?
What about other evens like DoubleClick?
How is this different from the RaiseEvent word?
RaiseEvent can only be used on class events that are not inherited.
For other events, you could try calling the event handler:
Code:PictureBox1_DoubleClick(Me.PictureBox1,EventArgs.Empty)
Calling the event handler isn't a good idea IMHO... if the control has a click event that can be handled, use the .PerformClick method. If you are performing actions in a click event of something that could be called outside of that click event, then perhaps that code should be in a sub that CAN be called directly, and then the event handler calls that sub.
-tg
Why ever not? Besides, that's for the DoubleClick, etc. events.