by Charles La » Tue, 15 Jun 2004 17:34:19
ay
I'm not sure I follow you when you talk about a SelectedObject.
If I can translate your example into my own, let's say I have a Device
object and a ShowStuff object. The ShowStuff object displays information
about the Device object, but knows nothing of the Device object per se [as I
am writing this I think a light is coming on]. As such, the handlers are
attached outside the ShowStuff and Device objects, so the ShowStuff object
does not know what events it is servicing and cannot therefore call
RemoveHandler. I should clarify that I am not removing the objects manually
in order to detach the handlers, as I realise that this does not work; it
was just a precursor to implementing this process.
If I had a SelectedObject property, what would it contain that could remove
the handlers w/o knowing which events had been attached? This question is
actually the subject of another post: 'How to iterate through a list of
sender events and detach all receiver handlers when given only the sender
and receiver as Objects'.
As you say, though, the fact that the handlers are not being detached is
probably not the cause of the app not closing.
I have just traced through the app again, and there are two ways that the
child form can be created:
Case 1.
a. User clicks toolbar button to create new, blank child form
b. User drags usercontrol onto form from toolbox
Case 2.
a. User selects file from open file dialog
b. File is opened and child form is recreated from file (xml)
In case 1, I can close the child form and close the app as normal. In case
2, I can close the child form but the app won't close. However, I cannot see
that the two methods are doing anything substantially different. The same
utility functions for creating the form and instantiating the usercontrol
are used in both cases.
I don't think you did, but anyway, there aren't any exceptions thrown. I
have all exceptions set to break into the debugger when they are thrown.
Charles
"Jay B. Harlow [MVP - Outlook]" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...
been
cancel
message
cancel
thought
all
the
Controls
MDIChild.Close!
taking
nothing
taking
nothing
wondered