W
Water Cooler v2
I have a frmLogin form and a frmMDI form.
In the Login button's click event in the Login form, I write:
frmMDI frm = new frmMDI();
frm.Show();
this.Close();
This causes the frmMDI to show up and then the application to exit. I
am suspecting this is because:
1. The frmLogin is the startup object that has the entry point Main();
and
2. The frmMDI class's object frm is a local reference inside the
btnLogin_Click event handler inside the frmLogin form. Hence, as soon
as the frmLogin closes, the reference to frmMDI gets garbage collected.
Is that suspicion true? If yes, then the way to get around this would
be to have a global reference to frmMDI somewhere in some global
namespace and just to allocate memory to that frmMDI within frmLogin
and just to show it in there and exit frmLogin.
Is that the way to go here? If yes, where do I declare the reference to
the frmMDI form?
PS: I do have a Globals class with all static members that are global
to the entire application. Should I put the reference to frmMDI in
there?
In the Login button's click event in the Login form, I write:
frmMDI frm = new frmMDI();
frm.Show();
this.Close();
This causes the frmMDI to show up and then the application to exit. I
am suspecting this is because:
1. The frmLogin is the startup object that has the entry point Main();
and
2. The frmMDI class's object frm is a local reference inside the
btnLogin_Click event handler inside the frmLogin form. Hence, as soon
as the frmLogin closes, the reference to frmMDI gets garbage collected.
Is that suspicion true? If yes, then the way to get around this would
be to have a global reference to frmMDI somewhere in some global
namespace and just to allocate memory to that frmMDI within frmLogin
and just to show it in there and exit frmLogin.
Is that the way to go here? If yes, where do I declare the reference to
the frmMDI form?
PS: I do have a Globals class with all static members that are global
to the entire application. Should I put the reference to frmMDI in
there?