Re: How to programmatically invoke Click event of the Button ?

Tech-Archive recommends: Fix windows errors by optimizing your registry



An open-ended "invoke any event on any object, even if I didn't create it"
is a really bad idea; however, one trick you could use here is a bit of
misdirection;

Currently:
* Control X has events A, B, C, which some other code subscribes to
* you want to invoke them, and can't (except for a few handy ones like
OnClick)

Possible solution:
* Control X has events A, B, C
* You write a proxy class Y, with events D, E, F (probably called the same
as A, B, C); it subscribes to A, B and C, while also providing OnD, OnE,
OnF; if A is caught, it calls OnD, etc
* Your other code subscribes to D, E, F

Now when you want to invoke the events, it calls OnD, etc; you never need
talk directly to the base object.

Just a thought. You could also inherit from the Controls directly, but this
could get messy and more complex

Marc


"Oleg Subachev" <oleg@xxxxxxx> wrote in message
news:uGESmDwTGHA.4956@xxxxxxxxxxxxxxxxxxxxxxx
There is Control.InvokeOnClick event that is also protected that you can
call to invoke the OnClick event on any other control as long as you have
reference to it.

Thanks.
But what if I need to invoke another event ?

Oleg Subachev




.


Quantcast