G
gavin
hi guys, I have a query about c# event handling that should be obvious
I am sure - but I am confused
Lets say I have two classes.
One is a user control with a tabcontrol on it
The other is a user control with a treeview on it.
Now, both of these controls are placed on a form. Both classes raise
events e.g. when the tab is changed on the first control, the tree
control wants to know about it and vice versca.
so far so good...
Now, given that these controls know NOTHING about each other, how on
earth do I register each as a listener of the other? Neither has a
reference to the other one.
Since they are both placed on the containing form I am assuming that
this containing form must act as an event proxy - i.e. it will listen
for all events raised and call the relevant public handler in each user
control embedded on it (since it has references to all of them).
Am I talking rubbish or is there a better way? In all the examples I
see its one way only, the subscriber MUST know about the event raising
class but my situation is that they both must subscribe to each other.
thanks for reading - having a bad code day
I am sure - but I am confused

Lets say I have two classes.
One is a user control with a tabcontrol on it
The other is a user control with a treeview on it.
Now, both of these controls are placed on a form. Both classes raise
events e.g. when the tab is changed on the first control, the tree
control wants to know about it and vice versca.
so far so good...
Now, given that these controls know NOTHING about each other, how on
earth do I register each as a listener of the other? Neither has a
reference to the other one.
Since they are both placed on the containing form I am assuming that
this containing form must act as an event proxy - i.e. it will listen
for all events raised and call the relevant public handler in each user
control embedded on it (since it has references to all of them).
Am I talking rubbish or is there a better way? In all the examples I
see its one way only, the subscriber MUST know about the event raising
class but my situation is that they both must subscribe to each other.
thanks for reading - having a bad code day
