I've been having problems figuring out a way to do this. I need it so that if the user opens form a and then later on buries that form under others, and they click the menu to open the form again that it just sets focus to it instead of opening another instance...
This is what I have now, is there a better, more elegant way of doing this or is this pretty much it?
//see if the form is already open, if it is, set focus to it, if not, open it
foreach (Form a in MdiChildren)
{
if (a is frmEditorAccounts)
{
//the form is open, set focus to it
a.BringToFront();
a.Activate();
break;
}
}
if (ActiveMdiChild == null || ActiveMdiChild.Name != "frmEditorAccounts")
{
//no forms are open
//open one
frmEditorAccounts Accounts = new frmEditorAccounts();
Accounts.MdiParent = this;
Accounts.Show();
}