如何防止表单对象关闭放置? [英] How do I prevent a form object from disposing on close?

查看:85
本文介绍了如何防止表单对象关闭放置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用MDIParent表格.当我关闭其子项时,该子项的对象将处置.有没有一种方法可以将儿童可见性设置为false而不是进行处理?

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?

推荐答案

默认情况下,关闭表单时,该表单将被处理.您必须重写Closing事件以防止它发生,例如:

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.
}

这篇关于如何防止表单对象关闭放置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆