B
BillE
Using vb.net 2008 windows forms.
How can a form which has been closed and disposed still attempt to handle a
custom event?
I have a form which inherits from a base form class.
The base class has a shared event which is raised when a property in the
base class changes (the property updates a shared variable value).
The form handles this event to refresh itself based on the new property
value.
This all works very nicely.
When I close the form I call me.dispose.
If the shared event in the base class is subsequently raised by another form
which inherits the same base class, I get an error in the form which was
already closed and disposed:
"Cannot access a disposed object."
The object refers to a combo box which is populated when the event fires, on
the form which has been closed and disposed.
I work around this by testing the IsDisposed property of the form when the
event fires, but I don't understand why this should be necessary.
Thanks
Bill
How can a form which has been closed and disposed still attempt to handle a
custom event?
I have a form which inherits from a base form class.
The base class has a shared event which is raised when a property in the
base class changes (the property updates a shared variable value).
The form handles this event to refresh itself based on the new property
value.
This all works very nicely.
When I close the form I call me.dispose.
If the shared event in the base class is subsequently raised by another form
which inherits the same base class, I get an error in the form which was
already closed and disposed:
"Cannot access a disposed object."
The object refers to a combo box which is populated when the event fires, on
the form which has been closed and disposed.
I work around this by testing the IsDisposed property of the form when the
event fires, but I don't understand why this should be necessary.
Thanks
Bill