Reader Level:
ARTICLE

MDI Forms in C#

On October 18, 2001 Articles | Windows Forms C#
This article show how to create the MDI Form. The following source code will provide the use of MDI Forms in C#.
  • 0
  • 0
  • 91294
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());
}
}

Prasad H

Prasad is working as a Software Development /Test Engineer in eBots Software (p) Ltd for ebots Inc .

  • 398rank
  • 751K readers
COMMENT USING

Trending up