D
David Adams
Hi,
I am afraid I am asking a very basic question, or just something that is not
possible.
I have a WinForm app that contains a Form (Form A), and then 20-30
UserControls/WinForms that are created by Form A. Form A calls a class to
populate a strongly typed DataSet (contains about 20 tables) that is to be
shared amongst the UC's and other Forms. Right now, I am passing this
DataSet to each and every UserControl/Form via the constructor and then
setting the local strongly typed DataSet reference in each UC/Form to the
parameter passed to it such as:
public UserControl1(dsEmployees ds)
{
this.mdsEmployees=ds;
}
This is getting to be quite tedious and I would much rather have a public
class that I can access the DataSet from Form A and every UC/Form as well.
The class would contain nothing but the DataSet mentioned above along with a
few other variables that I am also having to pass to each UC/Form. I would
like to instantiate this class in Form A, and somehow have it be availble to
each UC/Form without passing through the constructor or public property.
I tried creating a static member of the strongly typed DataSet similar to a
module in VB, but I want the object to be destroyed when Form A closes.
Is there a better solution out there?
Thanks,
Dave
I am afraid I am asking a very basic question, or just something that is not
possible.
I have a WinForm app that contains a Form (Form A), and then 20-30
UserControls/WinForms that are created by Form A. Form A calls a class to
populate a strongly typed DataSet (contains about 20 tables) that is to be
shared amongst the UC's and other Forms. Right now, I am passing this
DataSet to each and every UserControl/Form via the constructor and then
setting the local strongly typed DataSet reference in each UC/Form to the
parameter passed to it such as:
public UserControl1(dsEmployees ds)
{
this.mdsEmployees=ds;
}
This is getting to be quite tedious and I would much rather have a public
class that I can access the DataSet from Form A and every UC/Form as well.
The class would contain nothing but the DataSet mentioned above along with a
few other variables that I am also having to pass to each UC/Form. I would
like to instantiate this class in Form A, and somehow have it be availble to
each UC/Form without passing through the constructor or public property.
I tried creating a static member of the strongly typed DataSet similar to a
module in VB, but I want the object to be destroyed when Form A closes.
Is there a better solution out there?
Thanks,
Dave