There is not concept of "parent object" without you explicitly defining it in your code. The easiest way to accomplish this is just to have a reference to the parent object in the child object. The only reason things like windows controls and web controls have a notion of parent is because MS coded it that way (basically like what I have below).
Public Class Quiz Private m_Questions As New QuestionCollection() Public Sub New(...) ... For ... m_Questions.Add( New Question(Me) ) Next End Sub End Class Public Class Question Private m_Parent As Quiz Public Sub New( parent As Quiz ) m_Parent = parent End Sub End Class adam.. > -----Original Message----- > From: Unmoderated discussion of advanced .NET topics. > [mailto:[EMAIL PROTECTED] On Behalf Of > John Lomnicki > Sent: Thursday, June 10, 2004 1:59 PM > To: [EMAIL PROTECTED] > Subject: Re: [ADVANCED-DOTNET] HowTo Define a Business > Objects Parent Prop erty > > Steve, > > Yes that is what I want to do but a little differently. Here > I have two > classes the Quiz class has an instance variable typed as a > Question object. > From within the Question object I want to be able to identify > where it has > been instantiated and return a property for the "Parent" > object. The line > of code 'x = me.Parent.myValue' is the line I'm having issues > with. How can > I identify who my parent object is? > > Public Class Quiz > Friend Property myValue as Integer > Get > Return myValue > Set (Value as Integer) > myValue = Value > End Property > > Private _question as Question > > End Class > > Public Class Question > Private x as Integer > > Private Function Foo() > x = me.Parent.myValue > End Function > > End Class =================================== This list is hosted by DevelopMentorŪ http://www.develop.com Some .NET courses you may be interested in: NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls View archives and manage your subscription(s) at http://discuss.develop.com