Question : vb.net - close form on exit

hello there,
I have two forms in my project.. startup is form1 then form2 loads with a button click..
how can I make so that if I click the close button on form2 both forms closes not just form2..

Answer : vb.net - close form on exit

Another approach...
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
Public Class Form1
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim f2 As New Form2
        AddHandler f2.FormClosed, AddressOf f2_FormClosed
        f2.Show()
    End Sub
 
    Private Sub f2_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs)
        Me.Close()
    End Sub
 
End Class
Random Solutions  
 
programming4us programming4us