Single Instance Form in a MDI application





0/5 (0 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 };
frm.Show();
frm.Focus();
}
and usage
OpenForm<NewForm>();