as

Saturday 18 January 2014

MDI application example in C sharp .Net

Welcome friends - in this article I am going to explain how we can develop the MDI application in C#.Net.

What is MDI?

MDI stands for the multiple document interface. The Application supports multiple documents to be opened in the same Window. Excel application is the example of the MDI application.

How to design MDI application in C#.Net?

We can design application in c#.net with the below steps.
  1. We have to click on the new project in visual studio
  2. Then select Windows based Application
  3. Then you can click on add new item button
This will open new window with below options.


 You have to select MDI parent form. This form acts as a single user interface inside which other forms can be opened.

You can write below code in load event of the MDI parent.

            clean();
            Form1 x = new Form1();
            x.MdiParent = MDIParent1.ActiveForm;
            x.WindowState = FormWindowState.Maximized;
            x.Show();

As shown in above code, We have opened the form1 instance inside the MDI parent.
Please note that below statement will open the form inside MDI Parent Form.

           x.MdiParent = MDIParent1.ActiveForm;

You should also remember that we can open multiple forms inside MDI Parent in similar fashion.

We can access the currently loaded form in the MDI Parent by using below code


            ((Form1)this.Owner.ActiveMdiChild).executeQuery(sql);
     



What do you think on this topic? Please express your opinion through comment below.

Sponsored Links

Popular Posts

Comments

ShareThis