DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

No Duplicate Forms In MDI Parent

09.06.2007
| 3945 views |
  • submit to reddit
        //This will ensure that no duplicate copies of a child form is created in an //MDI_Parent

            //"Display" is the form name
            foreach (Form childForm in this.MdiChildren)
            {
                if (childForm.GetType() == typeof(Display))
                {
                    childForm.Focus();
                    return;
                }
            }
            Display frmDisplay = new Display();
            frmDisplay.MdiParent = this;
            frmDisplay.Show();