是否有可能重新使用.NET的WinForms窗体对象吗? [英] Is it possible to reuse a .NET WinForms Form object?

查看:166
本文介绍了是否有可能重新使用.NET的WinForms窗体对象吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个窗口被关闭,这是可能的,并建议,重新使用该窗口的表格实例来再次显示相同窗口?或者是要求或建议始终创建该类的一个全新的实例时,你会呈现出一个窗口。

Once a window has been closed, it is possible, and it is recommended, to reuse that window's Form instance to show the same window again? Or is it required or recommended to always create a brand new instance of the class when you will be showing a window.

这到底是什么归结为是无论是以往任何时候都调用Show()或ShowDialog的()不止一次对同一个对象,只要在窗口之间关闭在一个不错的主意。

What this really boils down to is whether it is a good idea to ever call Show() or ShowDialog() more than once on the same object, as long as the window is closed in between.

如果这是不推荐,背后的原因的解释,也将是AP preciated。

If this is not recommended, an explanation of the underlying reasons would also be appreciated.

推荐答案

没有,没有。

调用close结束调用Dispose,并且对象被认为是处置。

A call to Close ends up calling Dispose, and the object is considered disposed.

有一个在的隐藏的形式,然后再次显示它,但关闭它是一个明确的禁忌,因为状态是它被设置后,不确定的(当然,国家设置没有问题的,但使用它是与使用的东西,没有定义)。

There is no problem in hiding the form and then showing it again, but closing it is a definite no-no, since the state is undefined after it is disposed (well, the state is disposed, but using it is the same as using something that is undefined).

这篇关于是否有可能重新使用.NET的WinForms窗体对象吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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