all groups > dotnet windows forms > february 2006 >
You're in the

dotnet windows forms

group:

Kind of event overriding


Kind of event overriding Marius Horak
2/28/2006 4:25:09 AM
dotnet windows forms: I have an object that works with an external treeview
(myObject.TreeView = formTreeView)
On myObject.TreeView = formTreeView assigment an AftreSelect event is
being attached inside the object code.
The problem is that formTreeView may have its AfterSelect event that
will be executed before myObject AtferSelect when I want it to be
executed after.

But how to do it?


Re: Kind of event overriding Stoitcho Goutsev (100)
2/28/2006 9:15:14 AM
Marius,

You can't control the order of event processing. The idea behind this design
pattern is that you don't care and basically don't know how many listeners
you have, thus you don't care about the order of execution.

There are different design patterns such us "Chain of Responsibility" where
you can guarantee the order of execution.


--
HTH
Stoitcho Goutsev (100)

[quoted text, click to view]

Re: Kind of event overriding Nick Hounsome
2/28/2006 1:00:47 PM

[quoted text, click to view]

You can't.

The whole point of events as compared to public delegates is that you can't
mess with them from outside the class. If this wasn't the case you would
have a massive security hole.

You'll have to rethink your design - possibly derive your own class from
TreeView and create a new event to fire first.

Re: Kind of event overriding Marius Horak
3/1/2006 1:54:11 AM
[quoted text, click to view]

I must say this is a major overlook on a part of M$.

[quoted text, click to view]

I don't agree with a such approach.
Either I'm in control or I'm being controled by some stupid rules.

[quoted text, click to view]

The best way to get into a mess.

MH

Re: Kind of event overriding Stoitcho Goutsev (100)
3/1/2006 9:22:57 AM
Marius,

This is not overlook at all. This is the way this design patern is defined
and has to work.


--

Stoitcho Goutsev (100)

[quoted text, click to view]

Re: Kind of event overriding Nick Hounsome
3/1/2006 1:43:01 PM

[quoted text, click to view]

I don't think that you will find anyone to agree with you.

[quoted text, click to view]

You are in control of YOUR classes - why should you have control over
someone else's class that they don't want to give you?

As I said it is POSSIBLE to use a public multicast delegate (either as a
field or a property) instead of an event. In this case the user of your
class could add,remove or rearrange the order of delegate invocation at
will.

[quoted text, click to view]

No - it's quite straightforward: all events in the framework are fired from
virtual methods called "On..." . You just need to override the appropriate
method and raise your own event before calling the base implementation to
raise the original event.

Re: Kind of event overriding Nick Hounsome
3/2/2006 12:00:00 AM

[quoted text, click to view]

No - the big brother knows better what MOST people using C# want and
security comes high on the list.

BB neither knows nor cares what you as an individual want especially as,
according to your email address, your are nobody :-)

Re: Kind of event overriding Marius Horak
3/2/2006 2:19:20 AM
[quoted text, click to view]

Well, in such case M$ went mad when they made the KeyPress event public.
Can you imagine the mess one can create in an application when a user
types for example FCUK as a company name?

Re: Kind of event overriding Marius Horak
3/2/2006 2:21:13 AM
[quoted text, click to view]

Yes, yes, The Big Brother knows better what I want.

Re: Kind of event overriding Marius Horak
3/2/2006 4:21:30 AM
[quoted text, click to view]

There is no such thing as "security" for developers (just for end
users), this is just a tool limitation.
If a developer wants to do something he/she should be able to do it.
Remember, those stupid computers are here to serve people.

Security? Which system do you prefer when crossing a road?

German, where can cross a road only in selected places and you have to
wait for a green light or face penalty

or

UK, where you can cross a road at any place and time, but watch the
traffic before crossing.


Most of the progress was made by people who took a risk (even when they
had to break a rule or two).

MH

nobody@con.eu -> EU is one big con and due to stupid rules sooner or
later everyone will be "nobody" in EU. EU rules will control your life
Re: Kind of event overriding Stoitcho Goutsev (100)
3/2/2006 9:12:43 AM
[quoted text, click to view]

If you want it you should go ahead and implement it. The framework and the
languages gives you everything to do it.


--

Stoitcho Goutsev (100)

Re: Kind of event overriding Nick Hounsome
3/2/2006 1:57:51 PM

[quoted text, click to view]

Developers are also users of other developers libraries.

[quoted text, click to view]

You can do something stupid. But why do you expect MS ti help you? They are
busy enough doing their own stupid things :-)
[quoted text, click to view]

The analogy is not a good one - in neither case is your security enforced in
the same sense as we are talking about - they penalize breach of rules
rather than make it impossible - A better analogy would be a pedestrian
footbridge with no access to the road at all.

[quoted text, click to view]

We are not talking about rules here - If it was just a rule then you would
have just broken it and not posted a question.

If you want to take risks then write in C++ not C#.

[quoted text, click to view]

I can't argue with that :-(

P.S. We are in the wrong group here anyway - it should be the csharp one.

AddThis Social Bookmark Button