| foreach (Form chform in charr) { if (chform.Name == "Patients") // one instance of the form is already opened { chform.Activate(); found = true; break; // exit loop } else found = false; // make sure flag is set to // false if the form is not found } if (found == false) { Patients myPatients = new Patients(); myPatients.MdiParent = this; // The StartPosition property is essential // for the location property to work myPatients.StartPosition = FormStartPosition.Manual; myPatients.Location = new Point(0,0); myPatients.Show(); } } } } |