' Form2 Public Event CloseButtonClick As EventHandler Private Sub CloseButton_Click (sender As Object, e As EventArgs) Handles CloseButton.Click RaiseEvent CloseButtonClick(Me, EventArgs.Empty) End Sub
' Form1 Private WithEvents _form2 As Form2 Private WithEvents _form3 As Form3 Protected Overrides Sub OnLaod (e As EventArgs) MyBase.OnLoad(e) _form2 = New Form2() _form3 = New Form3() _form2.Show() _form3.Show() End Sub Private Sub Form2_CloseButtonClick (sender As Object, e As EventArgs) Handles _form2.CloseButtonClick If _form3 IsNot Nothing Then _form3.Close() End If End Sub Protected Overrides Sub OnFormClosed (e As FormClosedEventArgs) MyBase.OnFormClosed(e) If _form2 IsNot Nothing Then _form2.Close() End If If _form3 IsNot Nothing Then _form3.Close() End If End Sub Private Sub Form2_FormClosed (sender As Object, e As FormClosedEventArgs) Handles _form2.FormClosed _form2 = Nothing End Sub Private Sub Form3_FormClosed (sender As Object, e As FormClosedEventArgs) Handles _form3.FormClosed _form3 = Nothing End Sub