Introducing DotNetFunda.com on mobile http://m.dotnetfunda.com ! Be with DotNetFunda.com on the go !
Go to DotNetFunda.com
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 30027 |  Welcome, Guest!   Register  Login
Home > Articles > Windows Forms > Multiple Document Interface (MDI) Form

Multiple Document Interface (MDI) Form

Article posted by Bubbly on 9/24/2009 | Views: 7482 | Category: Windows Forms | Level: Beginner red flag


This article describes sample usage of MDI form.

Introduction
 

Multiple Document Interface (MDI) form –

MDI form closely resembles a standard form with one major difference – the client area of an MDI form acts as a kind of container for other forms. It means that an MDI form also called an MDI parent form, can display MDI children in it, which is how the multiple document interfaces work.

Creating MDI Applications :

MDI forms are useful when the users want to open more than one document at a time.

























Creating MDI Child Windows in Code :

For adding MDI child windows into our MDI parent form, first I’ll create a form class MDIChild and then i’ll create MDI child windows by creating and displaying a new object of the class each time the user clicks on New Option in File Menu bar in application. To make that new form object a child window of the MDI parent, MDIparent, we have to set its MdiParent property to the main window which also sets its IsMdiChild property to True. For working with number of child windows we need to store them in a array of forms.

Steps :

1. Add RichtextBox to MDIChild (to second form)

2. Set Dock property of Richtextbox to fill by clicking on the square shaped button in the properties window









3. Add following code in MDIParent.cs

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

namespace MyWinForms

{

public partial class MDIParent : Form

{

int NumberofForms = 0;

MDIChild[] Forms = new MDIChild[11];

public MDIParent()

{

InitializeComponent();

}

private void MDIParent_Load(object sender, EventArgs e)

{

}

private void newToolStripMenuItem_Click(object sender, EventArgs e)

{

NumberofForms +=1;

Forms[NumberofForms] = new MDIChild();

Forms[NumberofForms].Text = "Document" + Convert.ToString(NumberofForms);

Forms[NumberofForms].MdiParent = this;

Forms[NumberofForms].Show();

}

}

}

4. Finally Run the application. Click on File -> New



























If you like this article, subscribe to our RSS Feed. You can also subscribe via email to our Interview Questions, Codes and Forums section.

Page copy protected against web site content infringement by Copyscape
Found interesting? Add this to:



Please Sign In to vote for this post.

Experience:1 year(s)
Home page:http://www.angeldeeps.blogspot.com
Member since:Monday, September 14, 2009
Level:Bronze
Status: [Member]
Biography:Software Engineer
>> Write Response - Respond to this post and get points
Related Posts

In this article explains you how to create Stopwatch Application using C#.

This Article will explain how to work with the FlowLayoutPanel control which is new in the DotNet Framework 2.0

Display the images in the rdlc reports, where the images are retrived from the database.

Clear 10 or more textboxes in just one click.

The article will make use of the API " ShowWindow " from the user32 Dll and allow users to Minimise,Maximize and manuplate other windows from your DotNet Application

More ...
About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you found plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/28/2012 11:58:55 AM