Click here to Skip to main content
11,583,532 members (64,606 online)
Click here to Skip to main content

Tagged as

Single Instance Form in a MDI application

, 1 Oct 2011 CPOL 3K 3
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    Rant Rant    Admin Admin   

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

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