I have one Main form and two types of child form
MainForm
ChildFormA – unique
ChildFormB – have multiple forms of this type
I create ChildFormA with:
ChildFormA form1 = new ChildFormA();
form1.MdiParent = this;
form1.Show();
But when i close it with:
form1.Close();
I can’t re-open it.
I’ve already read some tips that I can Hide this form instead or closing it. But the X button still closes the form.
How to re-open or how to prevent the X button to close and simple hide it?
If you want your child form to remain in its state, you have to subscribe to the
FormClosingevent and set theCancelproperty of the event argument totrue.Keep in mind, that you’re form will not get disposed, if you don’t add more logic to this.
Otherwise, you can just create a new instance of it.