[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Closing all windows and returning to main menu

Posted on 2006-03-26
Medium Priority
Last Modified: 2010-04-16
When my program starts it has a main menu.  Depending on the options the user selects there can be up to 4 windows open.  At this point I have a timer which counts down to 0, and when it reaches 0 I want to close all of the windows and return to the main window.  

Is there a command to do this?

Question by:twibblejaway

Expert Comment

ID: 16296683
Hi  Twibblejaway,

I think that you should use a arraylist to store windows open.

ArrayList windowsopen = new ArrayList();

When you open a window, before show it, you add it to arraylist.


When you want to close all windows child, you convert each element to Form Object and close it.

for(int i = 0;i < windowsopen.Count;i++)

and remove all from windowsopen


Good luck,

LVL 86

Accepted Solution

Mike Tomlinson earned 1500 total points
ID: 16296720
If you are working in C# 2005, then use the Application.OpenForms() collection:

If you are using an Mdi approach, then use the MdiChildren() collection:

Otherwise, you need to manually track your open windows as vinhnl suggests.

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question