M
Michael.Suarez
Suppose I have a button on a form that opens up another form. the code
in the buttons click event is:
frmMyCustomForm frm = new frmMyCustomForm ();
frm.ShowDialog();
frm.Dispose();
The form opens, user does what they need, the form closes, and gets
disposed immediately afterwards, due to the fact that the program is
stuck on the frm.ShowDialog() line until the form closess.
But suppose I don't want to do ShowDialog. I just want to use
frm.Show(). In that case, the program would continue to the next line
and I certainly wouldn't want to immediately dispose it. Where do I
dispose it?
in the buttons click event is:
frmMyCustomForm frm = new frmMyCustomForm ();
frm.ShowDialog();
frm.Dispose();
The form opens, user does what they need, the form closes, and gets
disposed immediately afterwards, due to the fact that the program is
stuck on the frm.ShowDialog() line until the form closess.
But suppose I don't want to do ShowDialog. I just want to use
frm.Show(). In that case, the program would continue to the next line
and I certainly wouldn't want to immediately dispose it. Where do I
dispose it?