• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 213
  • Last Modified:

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!
0
ssdjgru1
Asked:
ssdjgru1
  • 2
  • 2
1 Solution
 
Bob LearnedCommented:
What version of .NET do you have?

Bob
0
 
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:
Hi, Mikey :)

Bob
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
G'Morning Bob!
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now