How To Use MDI In C#

An MDI(Multiple Document Interface) is a graphical user interface within which multiple windows reside below one parent window. The opposite words of MDI are SDI(Single Document Interface) and TDI(Tabbed Document Interface).

As usual create a new project, look for IsMdiContainer property in your Forms' properties and make it True.
MDI Properties

Add a new Windows Form

new windows form ya

Now we'll need to add some code to Declare the child form and show so you can make a button or something but I am going to do this in the Form_Load event :

// Declaring the child form
            Form2 BabyForm = new Form2();
            // Set the main form as a parent form
            BabyForm.MdiParent = this;
            // Show 
            BabyForm.Show();

Now just debug your program and see what happens; you'll have a child form LOL.

child form mdi csharp

Arranging the child Form/Forms :

Layout Cascade
this.LayoutMdi(MdiLayout.Cascade);

Tile Vertical
this.LayoutMdi(MdiLayout.TileVertical);

Tile Horizontal
this.LayoutMdi(MdiLayout.TileHorizontal);

Arrange Icons
this.LayoutMdi(MdiLayout.ArrangeIcons);

Thanks for reading this, this tutorial contains only the basics of MDI application.

1 comments:

Post a Comment