You cannot open (show; there is no "open") a form which was closed, because it is disposed. The most usual pattern here is to capture the attempt to close a form and cancel it, hiding it instead. To do so, you would need to either handle the event
System.Windows.Forms.Form.FormClosing
or override the virtual method
System.Windows.Forms.Form.OnFormClosing
. As you usually create a form class anyway, let's consider the second way:
public partial class MyForm
{
protected override OnFormClosing(FormClosingEventArgs e)
{
if (e.CloseReason == System.Windows.Forms.CloseReason.UserClosing)
{
Hide();
e.Cancel = true;
}
}
}
Please see:
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.onformclosing.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.formclosingeventargs.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.formclosingeventargs.closereason.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.closereason.aspx[
^].
Now, about MDI. Here is the idea: who needs MDI, ever? Why torturing yourself and scaring off your users?
Do yourself a great favor: do not use MDI at all. You can do much easier to implement design without it, with much better quality. MDI is highly discouraged even by Microsoft, in fact, Microsoft dropped it out of WPF and will hardly support it. More importantly, you will scare off all your users if you use MDI. Just don't. I can explain what to do instead.
Please see:
http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages[
^],
How to Create MDI Parent Window in WPF?[
^].
See also my past answers:
Question on using MDI windows in WPF[
^],
MDIContainer giving error[
^],
How to set child forms maximized, last childform minimized[
^].
—SA