SIGN UP MEMBER LOGIN:    
ARTICLE

MDI Forms in C#

Posted by Prasad H Articles | Windows Forms C# October 18, 2001
This article show how to create the MDI Form. The following source code will provide the use of MDI Forms in C#.
Reader Level:
Download Files:
 

Description :

The following source code will provide the use of MDI Forms in C#.



Source Code:

using System;
using System.Windows.Forms;
using System.ComponentModel;
using System.Drawing;
class MDIDemo:Form
{
private static int FormCount=0;
MainMenu mnuMain=
new MainMenu();
MenuItem FileMenu;
MenuItem NewMenu;
MenuItem ExitMenu;
MenuItem WindowMenu;
public MDIDemo()
{
this.IsMdiContainer=true;
this.Text="MDI Demo";
FileMenu=
new MenuItem();
FileMenu.Text="&File";
WindowMenu=
new MenuItem();
WindowMenu.Text="&Window";
WindowMenu.MenuItems.Add("&Cascade",
new EventHandler(Cascade_Click));
WindowMenu.MenuItems.Add("Tile &Horizontally",new EventHandler(TileH_Click));
WindowMenu.MenuItems.Add("Tile &Vertically",
new EventHandler(TileV_Click));
WindowMenu.MdiList=
true;
NewMenu=
new MenuItem();
NewMenu.Text="&New";
NewMenu.Click+=
new EventHandler(New_Click);
ExitMenu=
new MenuItem();
ExitMenu.Text="E&xit";
ExitMenu.Click+=
new EventHandler(Exit_Click);
FileMenu.MenuItems.Add(NewMenu);
FileMenu.MenuItems.Add(
new MenuItem("-"));
FileMenu.MenuItems.Add(ExitMenu);
mnuMain.MenuItems.Add(FileMenu);
mnuMain.MenuItems.Add(WindowMenu);
this.Menu=mnuMain;
}
private void Cascade_Click(object sender,EventArgs e)
{
this.LayoutMdi(MdiLayout.Cascade);
}
private void TileH_Click(object sender,EventArgs e)
{
this.LayoutMdi(MdiLayout.TileHorizontal);
}
private void TileV_Click(object sender,EventArgs e)
{
this.LayoutMdi(MdiLayout.TileVertical);
}
private void New_Click(object sender,EventArgs e)
{
Form frmTemp=
new Form();
frmTemp.MdiParent=
this;
frmTemp.Text="Window#" + FormCount.ToString();
FormCount++;
frmTemp.Show();
}
private void Exit_Click(object sender,EventArgs e)
{
this.Dispose();
Application.Exit();
}
public static void Main()
{
Application.Run(
new MDIDemo());
}
}

Login to add your contents and source code to this article
share this article :
post comment
 

WindowMenu is not defined anywhere. Where's the rest of the code?

This is a very inadequate and old example imo and should be removed from the website lest people see it and think c# corner is lame because its code examples are not good.

Posted by alan Jun 13, 2007
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Nevron Gauge for SharePoint
Become a Sponsor