473,396 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Parent reference (cross link) problem

Hi

It's a little hard for me to explain my problem, but i'll try. I have
an application in which i have a ManagerClass, many ClientClass-es ans
some ControlClass.
The ManagerClass creates one or more instances of ClientClass.
ClientClass creates some controls from ControlClass.
In the ControlClass i have derived some common control classes and
added some functionalities.

Here comes the problem:
when one Event handler from COntrolClass is fired , i need it to be
treated by the ManagerClass , depending on the state of the ClientClass
and the ControlClass that generated that event.

My approach , so far is working , but i'm sure it's not the best way to
do it , as i'm having lots of cross references:
the ClientClass is in a dll file, and i have it as a reference in
ManagerClass, so i can create instances of ClientClass from the
manager.
In ClientClass, in order to call a Method from the ManagerClass, i have
a reference to the ManagerClass, passed to the ClientClass Constructor.

THe same problem is with ControlClass and client class, same mechanism
used. is there any other way that i can do this?
thx

Nov 17 '05 #1
2 1464
Sidorf,

Correct me if I am wrong but it sounds as thought you have a parent child
relationship between your ManagerClass and the ClientClass and a parent
grandchild relationship between your ManagerClass and your ControlClass that
is contained in the ClientClass.

Your goal is to have notifications from ClientClass to your ManagerClass and
notifications from your ControlClass to the ManagerClass. So you want to
'bubble' events of importance from classes contained within other classes.

You should check using 'events' and 'delegates' in the .Net framework -
these are mechanism that allow you fire notifications to interested parties.
So you could setup an event on your ClientClass that is monitored by your
ManagerClass and you could also set up an event on your ClientClass that
fires when a ControlClass is added to the ClientClass have this monitored by
the ManagerClass and hence you can then setup another monitor for events on
the ControlClass - hope that isn't to confusing!

The approach described above does not require any of the children in the
parent child relationships to have an explicit reference to the parent.

http://msdn.microsoft.com/msdnmag/issues/01/08/net/
http://weblogs.asp.net/rosherove/arc...28/100444.aspx
http://www.codeproject.com/csharp/De...sAndEvents.asp

Check the links below:
HTH

Ollie Riches
"Sidorf" <ci************@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hi

It's a little hard for me to explain my problem, but i'll try. I have
an application in which i have a ManagerClass, many ClientClass-es ans
some ControlClass.
The ManagerClass creates one or more instances of ClientClass.
ClientClass creates some controls from ControlClass.
In the ControlClass i have derived some common control classes and
added some functionalities.

Here comes the problem:
when one Event handler from COntrolClass is fired , i need it to be
treated by the ManagerClass , depending on the state of the ClientClass
and the ControlClass that generated that event.

My approach , so far is working , but i'm sure it's not the best way to
do it , as i'm having lots of cross references:
the ClientClass is in a dll file, and i have it as a reference in
ManagerClass, so i can create instances of ClientClass from the
manager.
In ClientClass, in order to call a Method from the ManagerClass, i have
a reference to the ManagerClass, passed to the ClientClass Constructor.

THe same problem is with ControlClass and client class, same mechanism
used. is there any other way that i can do this?
thx

Nov 17 '05 #2
Hi Ollie
thanks for your quick reply. Seems like a solution to my problem. i'll
do some reading now and i'll post any further quiestions on delegates
issue.
Thanks again

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: DROdio | last post by:
I have a parent window that calls a popup, but via a semi convoluted process where it seems to lose its parent designation. I want that pop up to have a link which will a) close the pop up and...
25
by: Steve Jorgensen | last post by:
Yup, Steve's full of tips, but hey, it makes him feel important, right? Ok, here goes. I've been trying to improve encapsulation by putting code in the same object as the stuff it affects, so I...
5
by: superjacent | last post by:
Hope someone can help. I have a saved parent form containing an unbound sub-form. I set the SourceObject (form) after the Parent Form opens/loads. The sub-form (datasheet view) basically...
2
by: tvnaidu | last post by:
I cross compiled code for PPC on LINUX host - then I uploaded image to target, when I run on target - I get "GLIBC_2.4 not found, any idea?.
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.