How to create a MDI Child Form in VB.NET (Runtime Version)

This easy to understand code snipped shows you how to add a MDI Child Form to your MDI Container (or parent) Form.

Public Class Form1

 

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        ' Dinamically create a new Form called Form2

        Dim Form2 As New Form

        ' Tell Form2 to have aparent (Form1), means it has to be displayed inside Form1

        Form2.MdiParent = Me

        ' Add Caption to Form2

        Form2.Text = "Form2"

        ' Show Form2 (inside the client area of Form1

        Form2.Show()

    End Sub

End Class