Cannot access a disposed object?
What you can do is add a following check before calling .Show method:
if(_Max == null || _Max.IsDisposed)
_Max = new MaxForm();
_Max.Show();
and similarly for _Min form
Whenever a form is closed, all its resources are freed. This means that you can't access the object any more, since it no longer exists - it's been freed and deleted from memory. To prevent that, you can cancel the closing of the form, and hide it instead (which will appear transparent to the user).
this.Hide();
e.Cancel=true;
An updated version of your code is as follows:
private void Max_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
this.Hide();
this.Parent = null;
}
The problem is, that a closed form can not be used anymore (be reopened). Thats why the code you posted tries to stop closing and only hides your window. But for doing this, the Cancel-property must be set to true:
private void Max_FormClosing(object sender, FormClosingEventArgs e) {
this.Hide();
this.Parent = null;
e.Cancel=true;
}
To show the form after closing it this way, show it with the Show() method.
However this is probably only a workaround and you could solve the problem with another design. Maybe it would be wise, to create a new instance of your form, every time you need it, instead of trying to reopen it every time. This also has the advantage that the form only requesires resources if it is really needed.