0

除了我的主窗体之外,我还有另一个窗体 frmAddFixture,它可以打开 frmAddReport。

当从 msgbox 中选择“否”时,我只是试图关闭 frmAddFixture,这也关闭(成功)我(frmAddReport)。如果选择“是”,frmAddFixture 应该保持打开状态,它确实如此。但我不能让它关闭“不”。我尝试添加我自己的处理程序来检测 frmAddReport 何时关闭,但我无法让它工作。

frmAddReport 代码(在单击“提交”按钮后运行):

Private Sub showMsg()

Select Case MsgBox("Do you want to add another player report for this fixture?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Add further reports")

    Case MsgBoxResult.Yes
                    isNewFixture = False
    Me.Close()

    Case MsgBoxResult.No
                    isNewFixture = True
                    Me.Close()
                    ''Close frmAddFixture
                    'frmAddFixture.Dispose()
                    'frmAddFixture.Close()
                    'frmAddFixture.Hide()
        End Select
End Sub

尝试:

    Private Sub frmAddReport_FormClosed(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.FormClosed
        frmAddFixture.Dispose()
    End Sub
4

1 回答 1

1

这就是我认为你正在尝试做的事情。

让我们暂时忽略消息框,假设我们有两种形式:Form1Form2。我们希望它一旦被关闭Form2Form1也将被处理(关闭)。我很简单:

Public Class Form2

' Occurs when Form2 is closed (note the event handler).
Private Sub Form2_FormClosed(sender As Object, e As EventArgs) Handles MyBase.FormClosed
    Form1.Dispose()
End Sub
End Class
于 2015-04-09T21:17:04.407 回答