Click here to Skip to main content
15,893,814 members
Articles / Desktop Programming / Windows Forms

Single Instance Form in a MDI application

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
1 Oct 2011CPOL 8.1K   3  
private void OpenForm() where T : Form, new(){ T frm = (T)new List(this.MdiChildren).Find(f => f is T) ?? new T() { MdiParent = this }; frm.Show(); frm.Focus();}and usageOpenForm();

Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

Please Sign up or sign in to vote.
2 Oct 2011Manish K. Agarwal 3 alternatives  
Single Instance Form in a MDI application
Please Sign up or sign in to vote.
20 Sep 2011Ctznkane
Assuming you only want a single instance of a form type, I'd suggest you add a Dictionary(Of Type, Form). ShowOrActiveForm would have a single parameter of Type and would be a subroutine.The Form object could be found based on a ContainsKey. The rest of the ShowOrActiveForm function would be...
Please Sign up or sign in to vote.
28 Sep 2011Vladimir Vorobiev
This example contains the code to manage the menu of open forms (standard Windows menu). When created, each mdi-child gets a menu item and event handler through which this element is removed from the menu when the corresponding form is closed.private void ShowOrCreateMdiChild(Type formType)...

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Poland Poland
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions