How do I minimize all active forms in my application with a single button click?
I have multiple forms visible at a time, and I want all my active forms to minimize when I click on a single button on one of the forms.
How can I achieve this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you are not trying to minimize MDI child windows, you can simply loop through all of the open forms in your application and set their
WindowStateproperty to “Minimized”. VB.NET provides anOpenFormscollection for yourApplicationclass that makes this mind-blowingly simple.Place the following sample code into the
Clickevent handler of a button control, or similar method:If you want to minimize all of the forms when the user clicks the system minimize box on the title bar of a single form, you will need to listen in on that event, and execute the above code. Do this by overriding the
OnSizeChangedmethod for each form whose minimize events you want to apply to all open forms.You could also cause all of your forms to restore to the normal state whenever one of them is restored by clicking on its taskbar icon. Just reverse the same procedure used to minimize the windows, specifying a “Normal” window state instead of “Minimized”.
For example, you might write the following code: