>This is a little diffficult to explain, but I'll try.
>I have three classes:
>B (collection of A)
>C (contains a B object, an A object and another object we'll call objD)
>now when I do something like C.B.Add (parameters) in my main form, I will
>adding a new A object to the B collection of class C, but at the same time
>want to manipulate objD.
>Object A has similar properties to objD and I'd like keep them syncronized.
>Everytime a property of an A object is changed, I'd like to change the
>property of the corresponding objD as well.
>My question is how can I have access to objD in class module B?
>Is there a way to overwrite the add method of B in class C?
>The only way I could manage was by creating events in B and then
>manupulating objD in class C when B events occur. Is there another way?
>I know this sounds ambigious but if you have any ideas please let me know.
You could use Parent properties. Create a Public Object-type variable called
Parent in each class. When you create an instance of the class (an object),
you set it's Parent property to the object you are creating the class in.
Say you are creating a new instance of object A in your collection B. You
can have your AddItem method set a reference to object B in object A like
this, assuming the AddItem is a method of B:
Set A.Parent = Me
You can now access the properties and the methods of B from A, by using the
Parent. If you give object B a Parent property too, and make it a reference
to object C, you can access the properties of C from both B and A. Because
you can access object D from object C, you can use a syntax like this to
access a property in object D from an object A:
Parent.Parent.DObject.MyProperty="Created from A".
If you would like to synchronize object D with some object A, I would create
a method in object C wich can do this. It would take a reference to an
object A-type object, so the syntax would be (from within object A):
If object A and object D are realy the same type of objects, why not just
have a reference to object A itsef?
I hope this helps. If anyone got better ideas, please post them and CC to: