J
Jeremy
I've spent many hours on this issue, so someone please either tell me I'm an
idiot, or give me a hint on where to look.
My mdi child has a shared execute method which creates and shows it. When I
close the form, it visibly goes away, but it remains in memory. I know this
because ComboBox events fire for every supposedly "closed" instance of
frmMyMDIchild. Obviously there is either a nasty bug in VB, or I completely
misunderstand something very basic. Help me out here!
- Jeremy
Public Class frmMyMDIchild
Inherits System.Windows.Forms.Form
Shared frm As frmMyMDIchild = Nothing
Private ImDead As Boolean = False 'for debugging
Public Shared sub Execute(mdiParent as Form)
If frm Is Nothing Then
frm = New frmMyMDIchild
With frm
.midParent = mdiParent
'Do some inits ...
End With
End If
frm.Show()
End Function
Private Sub frmMyMDIchild_Closed(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Closed
Me.ImDead = True
frm.Dispose()
frm = Nothing
End Sub
Private Sub cbMyDropDown_SelectedValueChanged(ByVal sender as Object, ByVal
e As System.EventArgs) Handles cbMyDropDown.SelectedValueChanged
' **** This fires even for instances of frm where ImDead is True. ie: the
"Closed" frms are not closed at all.
msgbox(iif(ImDead,"Dead","Not Dead"))
End Sub
'** end **
idiot, or give me a hint on where to look.
My mdi child has a shared execute method which creates and shows it. When I
close the form, it visibly goes away, but it remains in memory. I know this
because ComboBox events fire for every supposedly "closed" instance of
frmMyMDIchild. Obviously there is either a nasty bug in VB, or I completely
misunderstand something very basic. Help me out here!
- Jeremy
Public Class frmMyMDIchild
Inherits System.Windows.Forms.Form
Shared frm As frmMyMDIchild = Nothing
Private ImDead As Boolean = False 'for debugging
Public Shared sub Execute(mdiParent as Form)
If frm Is Nothing Then
frm = New frmMyMDIchild
With frm
.midParent = mdiParent
'Do some inits ...
End With
End If
frm.Show()
End Function
Private Sub frmMyMDIchild_Closed(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Closed
Me.ImDead = True
frm.Dispose()
frm = Nothing
End Sub
Private Sub cbMyDropDown_SelectedValueChanged(ByVal sender as Object, ByVal
e As System.EventArgs) Handles cbMyDropDown.SelectedValueChanged
' **** This fires even for instances of frm where ImDead is True. ie: the
"Closed" frms are not closed at all.
msgbox(iif(ImDead,"Dead","Not Dead"))
End Sub
'** end **