这应该很简单,但我无法使其工作。我搜索了SO和Google,令人惊讶的是我还没有找到答案。当另一个表格关闭时,我想要做的就是关闭一个表单。第二种形式是在点击按钮时打开。当Form1关闭时,Form2也应该关闭。 Form2可能无法打开,因此我们需要检查它是否首先打开。这是我一直在努力:当另一个窗体关闭时关闭窗体
Private Sub frm_scu_config_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
' this isn't working
If Application.OpenForms().OfType(Of frm_scu_report_display).Any Then
Dim frmConfig As frm_scu_report_display
' Open the config form and pass the list of turbines
frmConfig = New frm_scu_report_display()
frmConfig.Close()
End If
End Sub
任何帮助,将不胜感激。
'如果Form2的状态并没有没有那么Form2.Close' – Plutonix
使用布尔变量作为标志.. – matzone
谢谢@Plutonix。如果我在if语句中抛出一个消息框,它会正确识别第二个表单是否打开,但它不会关闭它。 – mack