Share via

MDIForm Object for Visual Basic 6.0 Users

In Visual Basic 6.0, an MDIForm was a special type of form that acted as a container for an MDI (Multiple Document Interface) application. In Visual Basic 2008, any form with its IsMdiContainer property set to true can act as an MDI container.

Conceptual Differences

Child Forms and Multiple MDI Forms

In Visual Basic 6.0, setting the MDIChild property on a child form identifies it as a child of the MDI form; an MDI application can have only one MDI form.

In Visual Basic 2008, the MdiParent property replaces the MDIChild property and identifies the MDI form that will contain the child form; MDI applications can have multiple MDI containers.

BackColor and Picture Properties

In Visual Basic 6.0, the background color of an MDIForm can be changed by setting the BackColor property, and a background picture can be displayed by setting the Picture property.

In Visual Basic 2008, it is not possible to change the background color or display a picture on an MDI form. Although you can set the BackColor and BackgroundImage properties on the form, setting the IsMdiContainer property to true invalidates these settings.

AutoShowChildren Property

In Visual Basic 6.0, the AutoShowChildren property of an MDI form is used to automatically show an MDI child form when it is loaded. Standard forms do not have this behavior; calling the Load method loads but does not show the form.

In Visual Basic 2008, you must explicitly call the Show method in order to display an MDI child form.

Controls and Graphics on MDI Forms

In Visual Basic 6.0, it is not possible to add most controls to an MDIForm. You can only add docked controls such as the Menu, StatusBar, or ToolBar control. In addition, graphics methods such as Circle or Line cannot be used on an MDIForm.

In Visual Basic 2008, you can add any control to an MDI form; however the behavior may not be what you would expect. Any controls on a form with the IsMdiContainer property set to true will "float" on top of any MDI child forms. Although you can make calls to graphics methods in the Paint event, the graphics will not appear at run time.

Code Changes for MDI Forms

The following examples illustrate differences in coding techniques between Visual Basic 6.0 and Visual Basic 2008.

Code Changes for Showing MDI Child Forms

The following code demonstrates how to display five instances of an MDI child form.

' Visual Basic 6.0
Dim F(1 To 4) As New Form1
Private Sub MDIForm_Load()
   Dim i As Integer
   Load Form1
   For i = 1 To 4
      F(i).Caption = "Form" & i + 1
   Next I
End Sub
' Visual BasicPrivateSub MDIForm1_Load(ByVal sender As System.Object, ByVal e _
As System.EventArgs) HandlesMyBase.Load
  Dim i AsInteger = 0
  For i = 0 To 4
      Dim F AsNew FormChild
      F.Text = "Form " & CStr(i + 1)

Code Changes for Arranging MDI Child Windows

The following code demonstrates how to write code to change the arrangement of windows in an MDI application. It assumes that you have created menu items for each option.

' Visual Basic 6.0
Private Sub menuCascade_Click()
   Me.Arrange vbCascade
End Sub
Private Sub menuTileHorizontally_Click()
   Me.Arrange vbHorizontal
End Sub
Private Sub menuTileVertically_Click()
   Me.Arrange vbVertical
End Sub
' Visual BasicPrivateSub CascadeToolStripMenuItem_Click(ByVal sender AsObject, _
ByVal e As System.EventArgs) Handles CascadeToolStripMenuItem.Click

' Visual BasicPrivateSub TileVerticleToolStripMenuItem_Click(ByVal sender AsObject, _
ByVal e As EventArgs) Handles TileVerticalToolStripMenuItem.Click

' Visual BasicPrivateSub TileHorizontalToolStripMenuItem_Click(ByVal sender AsObject, _
ByVal e As EventArgs) Handles TileHorizontalToolStripMenuItem.Click


MDI Form Property and Method Equivalencies

The following table lists Visual Basic 6.0 properties and methods and their Visual Basic 2008 equivalents. Only properties and methods that are unique to the MDIForm object are listed — for other properties, methods, and events see Form Object for Visual Basic 6.0 Users.

MDIForm Properties and Methods

Visual Basic 6.0

Visual Basic 2008 Equivalent

ActiveForm property


Arrange method


AutoShowChildren property

New implementation. For more information, see MDI form Show behavior has changed.

BackColor property

New implementation. The background for an MDI form will always be the default (Control).

Picture property

New implementation. MDI forms in Visual Basic 2008 cannot directly display pictures.

Upgrade Notes

When upgrading a MDI application from Visual Basic 6.0 to Visual Basic 2008, any MDIForm objects are upgraded to regular forms and their IsMdiContainer property is set to true.

In Visual Basic 2008, the AutoShowChildren property no longer exists. To emulate the Visual Basic 6.0 behavior, a line of code is added during upgrade to show each child form if AutoShowChildren is set to true in the original application.

See Also


MDI for Visual Basic 6.0 Users

Form Object for Visual Basic 6.0 Users

Forms Tasks for Visual Basic 6.0 Users

Other Resources

Multiple-Document Interface (MDI) Applications