Parent and Child forms

BlackByte

Well-known member
Joined
Jun 29, 2008
Messages
126
Location
South Africa, Durban
Programming Experience
1-3
Hi i'm a biginner in vb.net and need your help
I am making an application with 3 forms. When the user clicks a button on the main form another form is displayed using the form2.showDialog method and the main form is hidden using the Main.Hide method,when the user closes the second form the 1st form is shown, then when the user clicks a button on the 2nd form a third form is diplayed using Form.showDialog method when this form closes instead of the 2nd form being displayed the first form is displayed. I want the forms to appear in a sequence as the user closes each form.
 
FrmMain button code

VB.NET:
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Hide() 'This hides frmMain
        Dim frm2 As New Form2 'You have to make a new instance of frm2

        frm2.Show() 'Show's frm2

    End Sub

frm2 button code

VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim frm3 As New Form3 'New instance of frm3

        Me.Close() 'Closes frm2
        frm3.Show() 'Shows frm3

    End Sub

Form 3 button event

VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Close() 'Closes frm3
        FrmMain.Show() 'Shows FrmMain again
    End Sub

Hope this helps

Redmo
 
Back
Top