So a child form calls it's Show() method, and i need it to close it but be available for reuse and i need the controls to be in the same state they were before it was closed. I was using the Close() method but when i try to reuse one of the controls i get a DisposedException saying you can't use a disposed object? How can i close the child form without disposing the controls?

Recommended Answers

All 2 Replies

Call Hide rather than Close, you can restore the form with Show.

using hide is a good method. But, if you create all your controls from a different form, then dynamically add them to the new form's control collection. The first form will have references to all the controls. Make sure that when you close the new form that you remove all the controls from the controls collection so they don't get disposed.

This system does infact work, but can get very messy. I would recommend Narue's suggestion of hiding the form unless its of the utmost importance that it be closed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.