If you need a list of open forms, then Application.OpenForms . You can iterate over this using GetType () and check .Assembly to find those from another assembly. Other than that, I don't quite understand the question ...
Assembly currentAssembly = Assembly.GetExecutingAssembly(); List<Form> formsFromOtherAssemblies = new List<Form>(); foreach (Form form in Application.OpenForms) { if (form.GetType().Assembly != currentAssembly) { formsFromOtherAssemblies.Add(form); } }
If you just want to keep track of the forms that you opened yourself, then cache this instance. Or, if you use "owned forms", you can simply check by name:
private void button1_Click(object sender, EventArgs e) { foreach (Form form in OwnedForms) { if (form.Name == "Whatever") { form.Activate(); return; } } Form child = new Form(); child.Name = "Whatever"; child.Owner = this; child.Show(this); }
source share