Multiple Document Interface (MDI)

9:18 AM / Posted by Alagan /

MDI Applications


MDI (Multiple Document Interface) Application is an application in which we can view and work with several documents at once. Example of an MDI application is Microsoft Excel. Excel allows us to work with several documents at once. In contrast, SDI (Single Document Interface) applications are the applications which allows us to work with a single document at once. Example of a single document application is Microsoft Word in which only one document is visible at a time. Visual Basic .NET provides great support for creating and working with MDI applications. In general, MDI applications are mostly used by financial services organizations where the user needs to work with several documents at once.

Creating MDI Applications

Let's create an MDI application. Open a new Windows Application in Visual Basic .NET. The application will open with a default form, Form1. Add another form, Form2 to this application by right-clicking on the project name in Solution Explorer window and selecting Add->Add Windows Form. You can add some controls to Form2. For this application we will make From1 as the MDI parent window and Form2 as MDI child window. MDI child forms are important for MDI Applications as users interact mostly through child forms. Select Form1 and in it's Properties Window under the Windows Style section, set the property IsMdiContainer to True. Setting it to true designates this form as an MDI container for the child windows. Once you set that property to true the form changes it's color. Now, from the toolbox drag a MainMenu component onto Form1. We will display child windows when a menu item is clicked. Name the top-level menu item to File with submenu items as New Child Window, Arrange Child Windows and Exit. The whole form should look like the image below.

With this application a new child window is displayed each time the New Child Window menu item is clicked, all child windows will be arranged when you click Arrange Child Windows menu item. To get the desired result, open the code designer window and paste the following code.


When you run the application and click "New Child Window" menu item, a new child window is displayed. Five child windows will be displayed as we declared an array of five in code. The image below displays the output.

When you click on "Arrange Child Windows" menu item, all child windows are arranged. It looks like the image below.





Creating Multiple Forms in VB .NET

It's a rare programme that only has one form in it. Most programmes will have other forms. These other forms can be used for things like Find and Replace searches, extra formatting capabilities, to set Options for the programme, and a whole lot more besides. VB.NET let's you add as many forms as you want to your project. But the process is not quite so simple. We'll see how to do it, though.
· Start a New project
· This will create a form called Form1
· To create a second form, click the Project menu
· From the drop down menu, click Add Windows Form
· The Add New Item dialogue box appears:
Loops

For Loop
The For loop is the most popular loop. For loops enable us to execute a series of expressions multiple numbers of times. The For loop in VB .NET needs a loop index which counts the number of loop iterations as the loop executes. The syntax for the For loop looks like thisThe image below displays output from above code.

While loop

While loop keeps executing until the condition against which it tests remain true. The syntax of while loop looks like this:
Example on While loop

Do Loop

The Do loop can be used to execute a fixed block of statements indefinite number of times. The Do loop keeps executing it's statements while or until the condition is true. Two keywords, while and until can be used with the do loop. The Do loop also supports an Exit Do statement which makes the loop to exit at any moment. The syntax of Do loop looks like this:



Example on Do loop



The image below displays output from above code













































Labels:

0 comments:

Post a Comment