Thursday, 29 May 2014

Open For MDI Parent Using C#.Net and VB.Net

5/29/2014 - By Pranav Singh 0

Whenever we create a windows application and if we are using MDP parent form in that case the process for opening form in MDI window is different as we open form in not in MDI parent.


Now for this article first we will create a new windows application and add two forms form1 and form2. Now take form1 and got to property window to make the for MDI window form. How to make a form 
MDI Form in window application C#.Net.



Here is the code for this article

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ProjectDemo_Windows
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void openForm2ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (CheckMdiClientDuplicatesForm("ProjectDemo-Windows.Form2") == true)
            {
                Form1 objform1 = new Form1();
                objform1.MdiParent = this;
                objform1.Show();
            }
        }
        public bool CheckMdiClientDuplicatesForm(string windowsFormName)
        {
            if (ActiveMdiChild != null)
            {
                if (ActiveMdiChild.Name != windowsFormName.Split('.')[1].ToString())
                {
                    ActiveMdiChild.Close();
                }
            }
            Form[] mdichld = this.MdiChildren;
            if (this.MdiChildren.Length == 0)
            {
                return true;
            }
            foreach (Form selfm in mdichld)
            {
                string str = selfm.Name;
                str = str.IndexOf(windowsFormName).ToString();
                if (str != "-1")
                {
                    return true;
                }
            }
            return false;
        }
    }
}

Now run the application


DOWNLOAD

About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Global Classified : Connectseekers.com
© 2014 aspdotnet-pools.com Designed by Bloggertheme9.
back to top