Throwing an event

  • Thread starter Thread starter Ot
  • Start date Start date
O

Ot

Can I raise (throw) an event that is normally created by, say, a button
click on a form?

I would like to react to a given situation exactly as if the user had
clicked that button. Is it "legal" to Throw that kind of event?
 
Yes, and you can call the Sub as well. Notice that the handler for Control
events is a sub (or void in C#). You can pass in an object and specific
event args, or just leave them as Nothing if you aren't using them in your
handler)
 
* "Ot said:
Can I raise (throw) an event that is normally created by, say, a button
click on a form?

I would like to react to a given situation exactly as if the user had
clicked that button. Is it "legal" to Throw that kind of event?

For the 'Click' event, you can call the button's 'PerformClick' method.
For other events, you can move the code from the handler into a separate
procedure and call this procedure from within the handler and from any
place where the "event" handler should be executed.
 
Back
Top