是否有可能重新使用.NET的WinForms窗体对象吗?有可能、窗体、对象、WinForms

2023-09-03 04:12:26 作者:撩妹课代表

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

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