Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / March 2006

Tip: Looking for answers? Try searching our database.

Kind of event overriding

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Marius Horak - 28 Feb 2006 12:25 GMT
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?

MH
Nick Hounsome - 28 Feb 2006 13:00 GMT
>I have an object that works with an external treeview
> (myObject.TreeView = formTreeView)
[quoted text clipped - 5 lines]
>
> But how to do it?

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.
Marius Horak - 01 Mar 2006 09:54 GMT
> You can't.

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

> 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.

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

> possibly derive your own class from TreeView

The best way to get into a mess.

MH
Nick Hounsome - 01 Mar 2006 13:43 GMT
>> You can't.
>
> I must say this is a major overlook on a part of M$.

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

>> 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.
>
> I don't agree with a such approach.
> Either I'm in control or I'm being controled by some stupid rules.

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.

>> possibly derive your own class from TreeView
>
> The best way to get into a mess.

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.
Marius Horak - 02 Mar 2006 10:19 GMT
> I don't think that you will find anyone to agree with you.

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?

MH
Stoitcho Goutsev (100) - 01 Mar 2006 14:22 GMT
Marius,

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

Signature

Stoitcho Goutsev (100)

>> You can't.
>
[quoted text clipped - 12 lines]
>
> MH
Marius Horak - 02 Mar 2006 10:21 GMT
> This is not overlook at all. This is the way this design patern is
> defined and has to work.

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

MH
Nick Hounsome - 02 Mar 2006 11:10 GMT
>> This is not overlook at all. This is the way this design patern is
>> defined and has to work.
>
> Yes, yes, The Big Brother knows better what I want.

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 :-)
Marius Horak - 02 Mar 2006 12:21 GMT
> No - the big brother knows better what MOST people using C# want and
> security comes high on the list.

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
(using computers and M$ software)
Nick Hounsome - 02 Mar 2006 13:57 GMT
>> No - the big brother knows better what MOST people using C# want and
>> security comes high on the list.
>
> There is no such thing as "security" for developers (just for end
> users), this is just a tool limitation.

Developers are also users of other developers libraries.

> If a developer wants to do something he/she should be able to do it.
> Remember, those stupid computers are here to serve people.

You can do something stupid. But why do you expect MS ti help you? They are
busy enough doing their own stupid things :-)

> Security? Which system do you prefer when crossing a road?
>
[quoted text clipped - 5 lines]
> UK, where you can cross a road at any place and time, but watch the
> traffic before crossing.

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.

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

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#.

> 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
> (using computers and M$ software)

I can't argue with that :-(

P.S. We are in the wrong group here anyway - it should be the csharp one.
Stoitcho Goutsev (100) - 02 Mar 2006 14:12 GMT
> If a developer wants to do something he/she should be able to do it.

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

Signature

Stoitcho Goutsev (100)

Stoitcho Goutsev (100) - 28 Feb 2006 14:14 GMT
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.

Signature

HTH
Stoitcho Goutsev (100)

>I have an object that works with an external treeview
> (myObject.TreeView = formTreeView)
[quoted text clipped - 7 lines]
>
> MH

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.