如何防止表单对象从处理上接近? [英] How to prevent a form object from disposing on close?

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

问题描述

我使用的MdiParent形式。当我关闭它的孩子,孩子的对象处置。有没有一种方法,以孩子的可见性设置为false,而不是处理?

I am using MDIParent Form. When I close its child, the object of the child disposes. Is there a way to set child visibilty 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.
}

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

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