473,683 Members | 3,573 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 1489
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
2166
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
6198
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
1574
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
8568
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8504
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,...
1
8753
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6429
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
5789
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
4299
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
4519
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2934
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2195
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.