Click here to Skip to main content
13,044,428 members (114,335 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


3 bookmarked
Posted 30 Sep 2011

Single Instance Form in a MDI application

, 1 Oct 2011
Rate this:
Please Sign up or sign in to vote.
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();
private void OpenForm<T>() where T : Form, new()
    T frm = (T)new List<Form>(this.MdiChildren).Find(f => f is T) ?? new T() { MdiParent = this };

and usage


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


About the Author

Rafał Klepacz
Software Developer
Poland Poland
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralThis solution is neat. Maybe it is even more useful to retur... Pin
wmjordan1-Oct-11 19:13
memberwmjordan1-Oct-11 19:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170713.1 | Last Updated 1 Oct 2011
Article Copyright 2011 by Rafał Klepacz
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid