|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Can a custom object know it's ownerdatatable is available inside a dataset. (VB.NET 1.1) I can't figure out how to make the child object know what object it's inside of. What I have is a custom object called Ageload which contains a custom collection designed to hold another custom object called a Batch. (Ageload, BatchCollection, Batch) When I use a dataset with a table in it, I can do something like: Datatable.Dataset (and get a reference to the dataset and all of it's functions/properties) I want to make my Ageloads and Batches do the same thing: Batch.Ageload (and get a reference to the Ageload) Thanks! Usarian Simply store a reference to the object in the child object. When you create
the child object, pass in the parent instance to initialize it. i.e.: Public Class ParentClass End Class Public Class ChildClass Private m_Parent As ParentClass = Nothing Public Readonly Property MyParent As ParentClass Get return m_Parent End Get End Property Public Sub New ( byval theParent As ParentClass ) m_Parent = theParent End Sub End Class Show quoteHide quote "Usarian" <noem***@nojunk.com> wrote in message news:OM$LLJH6GHA.4276@TK2MSFTNGP04.phx.gbl... >I am making some custom objects that operate "inside" each other, the way a >datatable is available inside a dataset. (VB.NET 1.1) > I can't figure out how to make the child object know what object it's > inside of. > > What I have is a custom object called Ageload which contains a custom > collection designed to hold another custom object called a Batch. > (Ageload, BatchCollection, Batch) > > When I use a dataset with a table in it, I can do something like: > Datatable.Dataset (and get a reference to the dataset and all of it's > functions/properties) > > I want to make my Ageloads and Batches do the same thing: > Batch.Ageload (and get a reference to the Ageload) > > Thanks! > > Usarian > I might have to do it that way. I'm already passing in about 6 values, and
wanted avoid making it any larger. Collections are new to me, so I thought that they might know who owns them. (But the Batch itself still wouldn't know it was in a collection anyway, so I'm still in the same boat.) I have to wonder how they made the datatable know what dataset contains it without passing that information in. Anyway, Thanks! Usarian Show quoteHide quote "Robinson" <toomuchspamhaspassed@myinboxtoomuchtoooften.com> wrote in message news:eg2t2l$3fs$1$8300dec7@news.demon.co.uk... > > Simply store a reference to the object in the child object. When you > create the child object, pass in the parent instance to initialize it. > i.e.: > > > > Public Class ParentClass > > End Class > > > Public Class ChildClass > > Private m_Parent As ParentClass = Nothing > > Public Readonly Property MyParent As ParentClass > > Get > return m_Parent > End Get > > End Property > > > > Public Sub New ( byval theParent As ParentClass ) > > m_Parent = theParent > > End Sub > > End Class > > "Usarian" <noem***@nojunk.com> wrote in message > news:OM$LLJH6GHA.4276@TK2MSFTNGP04.phx.gbl... >>I am making some custom objects that operate "inside" each other, the way >>a datatable is available inside a dataset. (VB.NET 1.1) >> I can't figure out how to make the child object know what object it's >> inside of. >> >> What I have is a custom object called Ageload which contains a custom >> collection designed to hold another custom object called a Batch. >> (Ageload, BatchCollection, Batch) >> >> When I use a dataset with a table in it, I can do something like: >> Datatable.Dataset (and get a reference to the dataset and all of it's >> functions/properties) >> >> I want to make my Ageloads and Batches do the same thing: >> Batch.Ageload (and get a reference to the Ageload) >> >> Thanks! >> >> Usarian >> > > > I have to wonder how they made the datatable know what dataset contains it You can be sure that information is passed through somewhere during > without passing that information in. > > > Anyway, Thanks! > Usarian > construction, perhaps behind the scenes. Hello Usarian,
Override your collection class's Add and AddRange methods. -Boo Show quoteHide quote > I am making some custom objects that operate "inside" each other, the > way a > datatable is available inside a dataset. (VB.NET 1.1) > I can't figure out how to make the child object know what object it's > inside > of. > What I have is a custom object called Ageload which contains a custom > collection designed to hold another custom object called a Batch. > (Ageload, BatchCollection, Batch) > > When I use a dataset with a table in it, I can do something like: > Datatable.Dataset (and get a reference to the dataset and all of it's > functions/properties) > > I want to make my Ageloads and Batches do the same thing: > Batch.Ageload (and get a reference to the Ageload) > > Thanks! > > Usarian >
Thread, UI update is this ok?
Redim Multidimenional Arrays MS Word Chart filled with data - URGENT PLEASE VB6 --> VB 2005 upgrade ...IDE now VERY slow!!! using strongly typed dataset update problem Compiling .dll's into a stand-alone .exe Importing DLLs during runtime Drag Bitmap tutorial/code anywhere? Encoding question FolderBrowserDialag? |
|||||||||||||||||||||||