I'm building an multiform Windows application that I anticipate will grow to
contain many forms. I would appreciate some "best practices" advice on the
cleanest way to call one form from another.
Up to now, I've called one form from another using the following syntax to
call one form from another. From my first form, the code looks like this:
frmMyForm2 frm = new frmMyForm2(this);
This is great, except that I have to specifiy a custom constructor in
frmMyForm2 to catch the passed parameter. The constructor would look like
this:
public frmMyForm2(frmMyForm1 frm)
{
InitializeComponent();
this.Show();
frm.Hide();
}
This isn't so bad if only one form is calling frmMyForm2. However, if this
form is central to the app there could easily be eight or ten forms calling
it. Rather than having to include eight or ten custom constructors in
frmMyForm2, is there some method of capturing the first form in the parameter
as a generic type so I only have to code one constructor?
Any advise or suggestions would be much appreciated. Thanks!
Andre