# CodeGuru Technical FAQs > CodeGuru Individual Visual Basic FAQs >  VB.NET 2003 Forms : How do I work with MDI forms?

## HanneSThEGreaT

*Q:* What is an MDI Form?

*A:* Multiple-document interface (MDI) applications allow you to display multiple documents at the same time, with each document displayed in its own window.

*Q:* How do I create an MDI Parent form?

*A:* In the Properties window, set the *IsMDIContainer* property of the form to *True*.

*Q:* How do I create an MDI child Form?

*A:* Add a new Windows Form (so that you have 2 forms).  In the MDI Form's Form_Load event, type the following :


```
 Dim MDIChildForm As New Form2()
MDIChildForm.MdiParent = Me
MDIChildForm.Show()
```

*Q:* How do I change the Background color of an MDI Parent form?

*A:* Eventhough there is a BackColor property in the Properties Window, it will not work as expected. Select the BackColor property in the Properties Window, and set it to a different color. You will not see the color of the MDI Form change in the Form designer. 
You have to type the following code into the MDI Form's Load event as well:


```
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ctl As Control
        Dim ctlMDI As MdiClient

        ' Loop through all of the form's controls looking
        ' for the control of type MdiClient.
        For Each ctl In Me.Controls
            Try
                ' Attempt to cast the control to type MdiClient.
                ctlMDI = CType(ctl, MdiClient)

                ' Set the BackColor of the MdiClient control.
                ctlMDI.BackColor = Me.BackColor

            Catch exc As InvalidCastException
                ' Catch and ignore the error if casting failed.
            End Try
        Next

    End Sub
```

*Q:* How do I add a Background picture to the MDI Parent form?

*A:* Simply set the BackgroundImage property of the MDI form, to the picture you want.  The picture will be tiled, once run.

*Q:* How do I check if an MDI Child form already exists, so that we don't show the same form twice ?

*A:* Inside the method from which you want to check (possibly a Menu item click, or toolbar) type the following :


```
        For Each f As Form In Me.MdiChildren
            If f.Text = "Form2" Then
                MessageBox.Show("It already exists!")
                Exit Sub
            End If
        Next
        Dim f2 As New Form2
        f2.MdiParent = Me
        f2.Show()
```

*Q:* How do I find out which MDI Child form is currently active?

*A:* Inside the particular event (in the MDI form) type the following :


```
        Dim ActiveMDI As Form = Me.ActiveMdiChild
        MessageBox.Show(ActiveMDI.Text)
```

*Q:* How do I arrange MDI Child windows?

*A:* Here are the Mdilayout options :
*Cascade*
Inside the particular event of the control on the MDI Parent, type :


```
Me.LayoutMdi(MdiLayout.Cascade)
```

*Tile Horizontal*
Inside the particular event of the control on the MDI Parent, type :


```
Me.LayoutMdi(MdiLayout.TileHorizontal)
```

*Tile Vertical*
Inside the particular event of the control on the MDI Parent, type :


```
Me.LayoutMdi(MdiLayout.TileVertical)
```

*Arrange Icons*
Inside the particular event of the control on the MDI Parent, type :


```
Me.LayoutMdi(MdiLayout.ArrangeIcons)
```

----------

