Your Ads Here

Thursday, 22 March 2012

How to create MDI Parent form in C#.NET

It shows how to create MDI parent and child form in C#.NET
Keywords: C#.NET, C Sharp.NET, MDI, ismdicontainer.

The foundation of a Multiple-Document Interface (MDI) application is the MDI parent form. This is the form that contains the MDI child windows, which are the sub-windows wherein the user interacts with the MDI application. Creating an MDI parent form is easy, both in the Windows Forms Designer and programmatically.

Steps to create MDI Parent.

Step 1: Click on the main form and takes its isMdiContainer propert in Property box, default value is false, change to true that will set your selected form to mdi parent. (your form background become grey color)

Steps to create MDI child.

For this add a button to your form and write below code into the button click event to open the child form.

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 testc
    public partial class Form1 : Form
        Form2 frm2 = new Form2();

        public Form1()

        private void button1_Click(object sender, EventArgs e)
            frm2.MdiParent = this;

Here your new form will open inside the main form.

No comments:

Post a Comment