MDI Form in VB.Net

In a Multiple Document Interface (MDI) program, the user has the ability to view and interact with multiple child windows simultaneously within the main application window. This stands in contrast to single document interface (SDI) applications, which restrict users to working with only one document or file at a time.

The MDI paradigm, as exemplified by applications like the Visual Studio Environment, offers a versatile and efficient approach for managing and organizing complex workflows. It allows users to seamlessly switch between different documents or views, facilitating multitasking and enhancing productivity.

vb.net-mdiform.jpg

In comparison, SDI applications, such as Notepad, limit users to working with a single document at any given time. Opening a new document within an SDI application typically results in the closure of any previously opened document. This straightforward approach simplifies the user interface and ensures a focused interaction with individual documents.

IsMdiContainer Property

In VB.Net, any window can be transformed into an MDI parent by setting the IsMdiContainer property to True. By designating a window as an MDI container, you enable it to serve as a host for multiple child windows. This property assignment allows for the creation of a hierarchical structure, where the main window acts as the parent container, and the child windows are nested within it.

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 mnore forms in the project (Form2 , Form 3) . Create a Menu on your form and call these two forms on menu click event. Click the following link to see how to create a Menu on your form How to Menu Control VB.Net.

NOTE: 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()
Full Source VB.NET
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

Conclusion

By exploring the MDI concept and appropriately configuring the IsMdiContainer property, you can create a sophisticated and efficient user interface that empowers users to work with multiple documents or views concurrently, developing a seamless and productive environment within your VB.Net application.