.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> C# >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Multiple Document Interface (MDI) form

Posted By:Deepika Haridas       Posted Date: September 24, 2009    Points: 25    Category: C#    URL: http://www.dotnetspark.com  
 

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 :

Add RichtextBox to MDIChild (to second form)

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

 

 

 

 

 

 

 

 

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






 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend