Link to home
Start Free TrialLog in
Avatar of derekl
derekl

asked on

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?
Avatar of smegghead
smegghead
Flag of United Kingdom of Great Britain and Northern Ireland image

What you can do is 'hide' the form rather than close it, this will prevent it from being disposed of.

Smg.
Avatar of derekl
derekl

ASKER

Which event do I need to override to provide this behavior?
ASKER CERTIFIED SOLUTION
Avatar of smegghead
smegghead
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial