Tutorials‎ > ‎VB Tutorials‎ > ‎

Launch and Manage MDI Child Forms

posted Jan 14, 2010, 8:38 PM by Tim Key   [ updated Jan 14, 2010, 8:39 PM ]

Change the words YourChildFormName to the actual string name of your child form.  Change the words YourChildForm to your acutal ChildForm object and the words YourParentForm to your actual MDI form object.


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        'Determine if the form is already active
        Dim f As Form = Nothing
        Dim Child As YourChildForm
        Dim FoundIt As Boolean = False
        For Each f In YourParentForm.MdiChildren
            If f.Name = "YourChildFormName" Then
                'Found it
                found = True
                Exit For
            End If
        Next f

        'Launch if it wasn't found
        If FoundIt = False Then
            Child = New YourChildForm
            With Child
                .MdiParent = YourParentForm
            End With
        End If
    End Sub