I have a form (frmMain
) that opens up another form (frmEdit
) modally.
This in turn opens up a third form (frmSelection
) modally.
My problem is that when frmSelection
is closed, frmEdit
also closes, yet nothing is actually closing it in my code.
Note the FormClosing
and FormClosed
events fire in the frmEdit
The code in frmMain
Using edit as New frmEdit
edit.ShowDialog
End Using
The code in frmEdit
:
Private Sub btnEditSelectionCriteria_Click(sender As Object, e As EventArgs) Handles btnEditSelectionCriteria.Click
Using sel As New frmSelection
sel.ShowDialog
End Using
End Sub
Private Sub btnOK_Click(sender As Object, e As EventArgs) Handles btnOK.Click
Me.Close ' this is not called (breakpoint is not hit)
End Sub
Private Sub frmEditTask_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
'This fires when OK button clicked in frmSelection
End Sub
The code in frmSelection
:
Private Sub btnOK_Click(sender As Object, e As EventArgs) Handles btnOK.Click
Me.Close ' this causes the FormClosing event to fire in frmEdit
End Sub
How can I track down what is closing my form? I thought there may be an exception being thrown but I checked Thrown in Common Language Runtime Exceptions to no avail.