articles

Home / DeveloperSection / Articles / WORKING ON MDI (MULTI DOCUMENT INTERFACE)

WORKING ON MDI (MULTI DOCUMENT INTERFACE)

Anonymous User9254 11-Sep-2010

In this Application we have to show the working of MDI Form and their various Properties with the help of an example. Choose a New Project and Name as MDISample, Next Right Click on the right hand side of MDISample and Click on ADD Option then Click on ADD item, then chooses an Option MDIParent Form as shown below as shown in arrow.

WORKING ON MDI (MULTI DOCUMENT INTERFACE)

As we click on MDIParent form you will see Below or we can use menus as well as ToolStrip task with the help of control as shown Below with the help of an Arrow.

WORKING ON MDI (MULTI DOCUMENT INTERFACE)

As in the above figure we can see all the functionalities as normal notepad as vertical tiles, Horizontal Tiles, cascade, close all, Arrange Icons etc.

The Code Snippet as shown below
publicpartialclassMDIParent1 : Form
    {
        privateint childFormNumber = 0;//Initializing childformno as 0.
 
        public MDIParent1()
        {
            InitializeComponent();
        }
 
        privatevoid ShowNewForm(object sender, EventArgs e)
        {
            Form childForm = newForm();//Creating Object of Form
            childForm.MdiParent = this;
            childForm.Text = "Window " + childFormNumber++;
            childForm.Show();
        }
 
        privatevoid OpenFile(object sender, EventArgs e)
        {
//Creating an object of openFileDialog and checking the open file into the same form.
            OpenFileDialog openFileDialog = newOpenFileDialog();
//openning the file as initial directory           
openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
openFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
            if (openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                string FileName = openFileDialog.FileName;
            }
        }
 
        privatevoid SaveAsToolStripMenuItem_Click(object sender, EventArgs e)
        { //Creating an object of savefile dialog
            SaveFileDialog saveFileDialog = newSaveFileDialog();
//saving the file in a initial directory           
            saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            saveFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
//Checking condition for save Dialog box
            if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                string FileName = saveFileDialog.FileName;
            }
        }
 
        privatevoid ExitToolsStripMenuItem_Click(object sender, EventArgs e)
        { //Closing the application
            this.Close();
        }
 
        privatevoid CutToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }
 
        privatevoid CopyToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }
 
        privatevoid PasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }
 
      privatevoid ToolBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            toolStrip.Visible = toolBarToolStripMenuItem.Checked;
        }
 
    privatevoid StatusBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            statusStrip.Visible = statusBarToolStripMenuItem.Checked;
        }
 
       privatevoid CascadeToolStripMenuItem_Click(object sender,EventArgs e)
        {//for cascading
            LayoutMdi(MdiLayout.Cascade);
        }

 

 

WORKING ON MDI (MULTI DOCUMENT INTERFACE)

 

 privatevoid TileVerticalToolStripMenuItem_Click(object sender,  EventArgs e)
        {//for Tile verticle
            LayoutMdi(MdiLayout.TileVertical);
        }

 

 

WORKING ON MDI (MULTI DOCUMENT INTERFACE)

 

 

  
        privatevoid TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e)
        {//For Horizontal
            LayoutMdi(MdiLayout.TileHorizontal);
        }

 

 

WORKING ON MDI (MULTI DOCUMENT INTERFACE)

 

        privatevoid ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e)
        {//for Arrange icons
            LayoutMdi(MdiLayout.ArrangeIcons);
        }

 

WORKING ON MDI (MULTI DOCUMENT INTERFACE)

 

 

    privatevoid CloseAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form childForm in MdiChildren)
            {//closing Form
                childForm.Close();
            }
        }
 

       

The Output of the code is shown as

WORKING ON MDI (MULTI DOCUMENT INTERFACE)



Updated 07-Sep-2019
I am a content writter !

Leave Comment

Comments

Liked By