• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

Form Disposal Question

I have a question about how and when an instance of System.Windows.Form get's disposed.  Here is the scenario:

I created a form, showd it and then put a reference to said form in a hashtable.  I then closed the form.  When I later attempted to access the object through the hashtable I got an exception saying it had been disposed.  Shouldn't the reference in the hashtable be sufficient to keep this form from being disposed?  If not is there anyway to prevent the form from being disposed on closure?  Finally if I can't prevent the disposal on closure is there any way to determin if a reference refers to an object which has been previously disposed?
0
derekl
Asked:
derekl
  • 2
1 Solution
 
smeggheadCommented:
What you can do is 'hide' the form rather than close it, this will prevent it from being disposed of.

Smg.
0
 
dereklAuthor Commented:
Which event do I need to override to provide this behavior?
0
 
smeggheadCommented:
this.Hide();

rather than

this.Close();
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now