Hi moondaddy,
The ChildClass will not have any reference to the ParentClass. Consider
this: an instance of ChildClass could be added to multiple ParentClass.
If you could guarantee an instance of ChildClass could only be added to one
ParentClass. You could create a public property in the ChildClass to hold
the reference to ParentClass and let the ParentClass.Add or Insert to set
this reference.
class ChildClass
{
private ParentClass _parent;
internal ParentClass Parent
{
get { return _parent; }
set { _parent = value; }
}
}
class ParentClass : CollectionBase
{
public int Add(ChildClass item)
{
if (item != null) item.Parent = this;
return List.Add(item);
}
public void Insert(int index, ChildClass item)
{
if (item != null) item.Parent = this;
List.Insert(index, item);
}
}
Regards,
Walter Wang (
[email protected], remove 'online.')
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.