VB.net - MDI Form
A Multiple Document Interface (MDI) programs can display multiple child windows inside them.
This is in contrast to single document interface (SDI) applications, which can manipulate only one document at a time. Visual Studio Environment is an example of Multiple Document Interface (MDI) and notepad is an example of an SDI application, opening a document closes any previously opened document. Any windows can become an MDI parent, if you set the IsMdiContainer property to True.
IsMdiContainer = True |
The following vb.net program shows a MDI form with two child forms. Create a new VB.Net project, then you will get a default form Form1 . Then add two more forms in the project (Form2 , Form 3) . Create a Menu on your form and call these two forms on menu click eventNOTE: If you want the MDI parent to auto-size the child form you can code like this.
form.MdiParent = Me form.Dock = DockStyle.Fill form.Show() |
Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load IsMdiContainer = True End Sub Private Sub MenuItem1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1ToolStripMenuItem.Click Dim frm2 As New Form2 frm2.Show() frm2.MdiParent = Me End Sub Private Sub MenuItem2ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2ToolStripMenuItem.Click Dim frm3 As New Form3 frm3.Show() frm3.MdiParent = Me End Sub End Class