VB.Net - MDI Application - Can a child borrow from a parent?

  • Thread starter Thread starter RonInOttawa
  • Start date Start date
R

RonInOttawa

I have an MDI application that has about a half dozen child forms. 3 or 4 of
them create the exact same dataset to retrieve information from a SQL Server
database and populate a combo box.

I was thinking that if I could simply create the datasets (2 of them) in the
parent then I would save a lot of time fetching stuff from the server and
would also eliminate a lot of useless network traffic. Since the parent is
always there, the data should persist - Right?

So, is it possible to access the datasets created in the parent from the
children?

Thanks

Ron...
 
Hi,

Yes. Your dataset must be a public form level variable for it to be
available to other objects.

Dim ds as dataset = DirectCast(Me.MdiParent, Form1).dataset1

Replace Form1 with name of the parent form.



Ken
 
* "RonInOttawa said:
I have an MDI application that has about a half dozen child forms. 3 or 4 of
them create the exact same dataset to retrieve information from a SQL Server
database and populate a combo box.

I was thinking that if I could simply create the datasets (2 of them) in the
parent then I would save a lot of time fetching stuff from the server and
would also eliminate a lot of useless network traffic. Since the parent is
always there, the data should persist - Right?

So, is it possible to access the datasets created in the parent from the
children?

Inside the child:

\\\
DirectCast(Me.MdiParent, MainForm).MyDataSet1.<...> = <...>
///
 
Back
Top