R – Is it possible to reuse a .NET WinForms Form object


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.

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.

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

Best Solution

No, and no.

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