473,657 Members | 2,507 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1480
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.goo glegroups.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
2164
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 b) redirect this "semi" parent window to another URL. I could name the semi-parent window something, if that would help. All the ideas I've seen online have to do with calling back to parent windows, but they don't work for me.
25
6194
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 rarely refer to a subform ir parent form's controls or records from the other form. Instead, I call a procedure in that form that does the job. That's all fine and good, and nothing at all revolutionary, but it leaves one with an annoying...
5
2589
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 displays the results of a cross-tab query The cross-tab query is created dynamically (in code) as the column headings are subject to change. I therefore have to create a new form (in code) and add the necessary
2
1572
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
8305
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8825
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6163
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4302
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1953
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.