All opened forms

Does anybody know how to get all opened forms that exist in program? (Background: I would like to close all forms (all but main) that are opened after the timer on main form runs out.)
If you have MDIContainter it is simple:  foreach (Form frm in this.MdiChildren) and you get them. I would like to do something similar with non MDI form if it's possible.

Thank you!
ssdjgru1Asked:
Who is Participating?
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
If you have C# 2005 then use the Application.OpenForms collection :
http://msdn2.microsoft.com/en-us/library/system.windows.forms.application.openforms(VS.80).aspx

If you don't have an MDI app then you have to track all open forms manually by keeping references to them in a list such as the ArrayList.  Subscribe to the forms closing event so you can remove it from your list when the form is closed...
0
 
Bob LearnedCommented:
What version of .NET do you have?

Bob
0
 
Bob LearnedCommented:
Hi, Mikey :)

Bob
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
G'Morning Bob!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.