How do I prevent a form object from disposing on close?

后端 未结 5 594
南方客
南方客 2020-12-06 10:27

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?

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-06 10:46

    You can cancel the close event and hide instead.

    private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            e.Cancel = true;
            this.Hide();
        }
    

提交回复
热议问题