Hi, I want to close a form, when another form closes. Basically, I have a search form that opens up a results form, which contains a dataGridView only. when the user closes the results form, I want the search form to close also. Is this even possible?
Thanks
jay_el_em 0 Light Poster
Recommended Answers
Jump to PostDo you want to close the application, or are other forms open?
Jump to PostThis is not a good way to close the form. You better do a loop of all forms, and then check which you want to select. Selected put into an array (pre-created), and when the code goes throught the loop (when it ends), go through the array of forms, and …
Jump to PostHeres an example:
List<Form> list = new List<Form>(); foreach (Form f in Application.OpenForms) if (f.Name == "Form2") list.Add(f); //close seleced (in this case only FindFrm will be closed: foreach (Form f in list) f.Close();
Maybe some forms do not have set the NAME propety. So you will …
All 10 Replies
Momerath 1,327 Nearly a Senior Poster Featured Poster
ddanbe 2,724 Professional Procrastinator Featured Poster
jay_el_em 0 Light Poster
jay_el_em 0 Light Poster
jay_el_em 0 Light Poster
jay_el_em 0 Light Poster
Mitja Bonca 557 Nearly a Posting Maven
jay_el_em 0 Light Poster
Mitja Bonca 557 Nearly a Posting Maven
jay_el_em 0 Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.