Closing forms (visually) and reusing them later

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm facing the same problem as many (according to google), i.e. if I close a form (Me.close) and later on I try to reuse it, sometimes (but not always) I get a 'ObjectDispossedException'.

I tried to use Hide instead of Close, but apparently the parent form does not regain control. After calling Me.Hide(), the screen displays the windows logo, etc. What I want to happen is that the parent form gets the focus again - as if I had closed the child form, except that I don't want to dispose it, just don't display it.

Any hints? What's the correct way to have two forms, and the first one being able to display the second one as often as needed, without creating a new instance each time?

Thanks.
 
I use a global variable to hold a "pointer" to the parent form. When I hide the form I want to "close" (but re-use later), I use the global variable to "show" the parent form again. Not necessarily the most elegant solution, but it works.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top