我有一个表单 ( frmMain
) 以模态方式打开另一个表单 ( frmEdit
)。
这反过来又打开了第三种形式 ( frmSelection
) 模态。
我的问题是何时frmSelection
关闭,frmEdit
也关闭,但在我的代码中实际上没有关闭它。
注意FormClosing
和FormClosed
事件在frmEdit
中的代码frmMain
Using edit as New frmEdit
edit.ShowDialog
End Using
中的代码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
中的代码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
如何追踪关闭表单的原因?我认为可能会引发异常,但我检查了在 Common Language Runtime Exceptions 中引发的异常,但无济于事。