MDI Applications in Visual Basic .NET
In this article, I will explain you about MDI Applications in Visual Basic .NET.
In this article, I will
explain you about MDI Applications in Visual Basic .NET.
In Visual Basic .NET
when we need to work with several documents at once then we use MDI (Multiple
Document Interface) Application.
We use MDI application where the user might like to have multiple forms or
documents open concurrently. In most real time applications we often find that
multiple windows open within another window. This can be done by implementing
Multiple Document Interface (MDI) Applications. MDI is also handy when your
application is too large, and you want to provide a simple mechanism for closing
all the child forms when the user exits the application. Microsoft Excel is
the example of an MDI application because it allows us to work with several
documents same time. Microsoft Word is the example of Single Document Interface
allows us to work with a single document at once.
Creating MDI Applications
In Visual Basic .NET
see how we create an MDI application. Open a new
Windows Application in
which there is a form named Form1.
Add another form, Form2 to
this application for this you have to right-clicking on the project name in Solution Explorer and
select Add->Add Windows
Form.We will make From1 as
the MDI parent window and Form2 as
MDI child window. To make Form1as
MDI parent select Form1 and
in its Properties Window,
set the property IsMdiContainer toTrue.
Once you set that
property to true the Form1 acts
like an MDI container for the child forms. It also changes its color and look
like the image below:
Now, from the toolbox
drag a MenuStrip onto Form1.
We will display child windows when a menu item is clicked. Name the top-level
menu item to New with submenu items as New Child Window, Arrange Child Window
Public Class Form1
Dim ChildF As Integer =
Dim ChildForms(6) As Form2
an array to store child windows
child windows (Form2) will be displayed
Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs)
ChildF += 1
ChildForms(ChildF) = New Form2()
ChildForms(ChildF).Text = "ChildForm" &
title for child forms and incrementing the number with an array
ChildForms(ChildF).MdiParent = Me
Private Sub ArrangeChildWindowToolStripMenuItem_Click(ByVal sender As System.Object, ByVale As System.EventArgs)
child windows on the parent form with predefined LayoutMdi method
layouts available are, ArrangeIcons, Cascade, TileHorizontal, TileVertica
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs)
The output window is look like the image below:
I hope this article
help you to understand about MDI Applications in Visual Basic .NET.