471,309 Members | 1,075 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,309 software developers and data experts.

Question on events

Hi All,
when you chain an event eg tb.Enter+= ; Is it possible to ensure I will get the first bite at the event
and also is it possible to refuse access to this event lower down the chain.

hope my question makes sense.
thank you.
Jan 10 '06 #1
4 1010
It didn't make sense to me, but I'm not so smart anymore since I stuck
my fork in the power outlet...

What chain are you talking about?
What "bite" are you talking about?

Are you asking that in the event handling method if you will get the
first character in the textbox?
And are you also asking if it is possible to prevent other objects
which can see your textbox object, from also handling the same event?

I feel like a monkey without a banana in this thread.

Jan 11 '06 #2
No, you'll need to create a specially built class to do that.

Jan 11 '06 #3
Hello,

I don't think you can stop the execution of the other methods once the event
has been fired.

Note that doing "tb.Enter = new ..." with delele all the previous methods
that where
registered with the event.

--
Francois Beaussier

<Co**********@al.com> a écrit dans le message de news:
11***************@eunomia.uk.clara.net...
Hi All,
when you chain an event eg tb.Enter+= ; Is it possible to ensure
I will get the first bite at the event
and also is it possible to refuse access to this event lower down the
chain.

hope my question makes sense.
thank you.

Jan 11 '06 #4
> Is it possible to ensure I will get the first bite at the event

No. Even if you could know for sure the order that the handlers will be
called by the event delegate, you should never depend upon that.

If you are subclassing, then you should override the OnEnter() method
rather than subscribing to the Enter event, for exactly this reason.
However, if your event subscriber is not a subclass of the class that
defines the Enter event, then there are no guarantees about the order
in which you'll be called.
it possible to refuse access to this event lower down the chain


Technically, no, but a similar mechanism does exist in .NET. Take a
look at KeyPressEventArgs: event arguments that contain a boolean
(Handled) that indicates "I've already handled this... don't bother
with it." In this case, however, it's not events "lower down the chain"
that are being advised that the event has been "handled," but rather
the default behaviour in the defining class that kicks in _after_ the
event is raised and only if Handled comes back from all event handlers
as false.

Jan 11 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by dixp | last post: by
reply views Thread by OutOfAlignMent | last post: by
5 posts views Thread by ECVerify.com | last post: by
4 posts views Thread by Andrew S. Giles | last post: by
44 posts views Thread by craig | last post: by
10 posts views Thread by jack | last post: by
4 posts views Thread by DeveloperX | last post: by
16 posts views Thread by RSH | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.