I am using an MDIParent Form. When I close its child, the object of the child disposes. Is there a way to set child visibility to false instead of disposing?
By default, when you close a form, it will be disposed. You have to override the Closing
event to prevent it, for example:
// Use this event handler for the FormClosing event.
private void MyForm_FormClosing(object sender, FormClosingEventArgs e)
{
this.Hide();
e.Cancel = true; // this cancels the close event.
}
You can cancel the close event and hide instead.
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
this.Hide();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With