1
我有一個表單(frmMain
),它以模態方式打開另一個表單(frmEdit
)。FormClosing事件在我致電Me之前觸發。關閉
這又打開了第三種形式(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
如何追蹤什麼是關閉我的表單?我認爲可能有一個異常被拋出,但我檢查了拋出公共語言運行時異常無濟於事。
的
DialogResult
財產在快速測試我無法重現你的症狀。但是,在附註中,不是'Me.Close',而應該設置DialogResult類似於:'Me.DialogResult = Windows.Forms.DialogResult.OK' –您是否將frmSelection的所有者指定爲frmEdit? http://stackoverflow.com/q/816885/2258 –
@RichardMorgan - 這沒有任何影響 –