Re: Overwriting event handler
- From: "Jose Fernandez" <ppcuban@xxxxxxxxxxx>
- Date: Thu, 7 Dec 2006 19:12:17 -0500
Ok. let me explain better
all i want is to change the name of the method in the Eventhandler to my
custom method IF some security criteria are not met. So, when the user
clicks on a button ('cause i want it to be able to be clicked) it will call
the design-time method or my method (which is a Supervisor Form). I can doit
inserting one line of code in every method definition in design time... but
that's a pain when i have more than 200 Forms and every form at least 2
buttons.
So, all i am creating is a base class that is the parent of every form, so i
check in every from that gets loaded its buttons.
I don't think that's something crazy.
Any idea?
"Jon Skeet [C# MVP]" <skeet@xxxxxxxxx> wrote in message
news:MPG.1fe2a352ff69f78498d6d1@xxxxxxxxxxxxxxxxxxxxxxx
Jose Fernandez <ppcuban@xxxxxxxxxxx> wrote:
Well.. maybe this is not the way... but there has to be a way to know who
subscribed to an event in an object.
No, there isn't.
I am gonna try using reflection. There has to be a way.
Why? What makes you think there will definitely be a way? There's no
way of doing it in a totally general way, as events can be implemented
however the author chooses.
Note that even if you can find a way which works for the current
implementation of the classes you're interested in, there's nothing to
stop MS from changing the implementation in the future.
If you want to unsubscribe from events, you'll need to know what the
original subscriptions are. If you're responsible for all the
subscriptions, you can keep track of it yourself. If you're not, it's a
huge breakdown of encapsulation to unsubscribe someone else's handlers
for someone else's events.
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.
- Follow-Ups:
- Re: Overwriting event handler
- From: RobinS
- Re: Overwriting event handler
- References:
- Overwriting event handler
- From: Jose Fernandez
- Re: Overwriting event handler
- From: Jon Skeet [C# MVP]
- Re: Overwriting event handler
- From: Jose Fernandez
- Re: Overwriting event handler
- From: Jon Skeet [C# MVP]
- Overwriting event handler
- Prev by Date: Re: Custom sorting for ListView
- Next by Date: Re: Clarifying Usage of AddingNew with BindingSource
- Previous by thread: Re: Overwriting event handler
- Next by thread: Re: Overwriting event handler
- Index(es):
Relevant Pages
|