R
RvGrah
I've looked (probably too briefly) at using the singleton class, and
I'm at bit worried about that approach, so I'm using another one.
In my parent form, which is just a form with buttons to launch
individual modules that do the actual work in a PO system, I create a
variable for each child form it might open. Each child form has a
declare in the form of:
public frmPoMain myDad;
and when any child form is launched, the parent form checks to see if
the form already exists, and if not creates and launches it:
if (fChoose == null)
{
fChoose = new frmChoosePO();
fChoose.myDad = this;
}
fChoose.Show();
fChoose.BringToFront();
In the child form, in the FormClosing event, it sets the parents
reference to null so the parent will know whether to create and show
the form, or only to show it.
This works fine, but is there a simpler way of doing this that doesn't
involve passing public variables back and forth between the child and
parent? It seems a bit fragile the way I'm doing it, but maybe I'm
just being paranoid. I don't want to use ShowDialog() because my users
sometimes need several child windows available at the same time.
Bob Graham
I'm at bit worried about that approach, so I'm using another one.
In my parent form, which is just a form with buttons to launch
individual modules that do the actual work in a PO system, I create a
variable for each child form it might open. Each child form has a
declare in the form of:
public frmPoMain myDad;
and when any child form is launched, the parent form checks to see if
the form already exists, and if not creates and launches it:
if (fChoose == null)
{
fChoose = new frmChoosePO();
fChoose.myDad = this;
}
fChoose.Show();
fChoose.BringToFront();
In the child form, in the FormClosing event, it sets the parents
reference to null so the parent will know whether to create and show
the form, or only to show it.
This works fine, but is there a simpler way of doing this that doesn't
involve passing public variables back and forth between the child and
parent? It seems a bit fragile the way I'm doing it, but maybe I'm
just being paranoid. I don't want to use ShowDialog() because my users
sometimes need several child windows available at the same time.
Bob Graham