我知道這個問題是一個老問題,你現在可能已經想通了,但我想我會爲將來的參考添加一個答案。所有Forms
都有FormClosing和FormClosed您可以在創建窗體中附加處理程序的事件。這是我想說的一個簡單的例子。
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.Hide()
If MsgBox("Open Report?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
Dim frm2 As Form2 = New Form2
AddHandler frm2.FormClosed, AddressOf ReportClosing
frm2.Show(Me)
Else
Me.Show()
'Do your work for printing form here
End If
End Sub
Private Sub ReportClosing(sender As Object, e As FormClosedEventArgs)
'Remove handler to prevent memory leaks
RemoveHandler DirectCast(sender, Form2).FormClosed, AddressOf ReportClosing
Me.Show()
End Sub
End Class
你使用類似的最頂層或ShowDialog的? – jAC 2013-02-14 05:55:30
我沒有使用上面提到的任何一個。 :-( – 2013-02-14 06:02:05
都是'Forms'在當時打開,'MessageBox'出現嗎? – jAC 2013-02-14 06:56:29