Home All Groups Group Topic Archive Search About

User Control's Load event fires when the Dispose method executes

Author
30 Nov 2004 6:43 PM
moondaddy

I have a user control which is used as a data entry form and it is
instantiated on a window form.  When the windows form is closed via clicking
on the top right red-X close button, the user control's Dispose method
executes.  When it executes the load event fires.





Here's the dispose method:

    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

        If disposing Then

            If Not (components Is Nothing) Then

'WHEN THE NEXT LINE EXECUTES, the controls Load Event Fires.

                components.Dispose()

            End If

        End If

        MyBase.Dispose(disposing)

    End Sub





This user control also created instances of some other user controls used as
sub-forms. I don't know if this has anything to do with it, but when the
user clicks on the red-X   close button of the parent form and things began
to close, no cleanup code ran to kill the instances of these user controls.
I will eventually have the proper cleanup code in place, but right now I
want to understand why this load event fires when "components.Dispose()" is
called.



Thanks.


--
moondaddy@nospam.com

Bookmark and Share