Start New Discussion within our Software Development Community

Hey, guys.

I was assigned to a project in my company. It's an application for another company, it was almost completely done, I was just making a few requested changes.
When you run the app, it opens a form. After you identify yourself, another form open up (the first one remains open). You select the thing you wanna check (I won't go into the details about what the application does), another form open. If you wanna change something, another form shows up.
The thing is, whem you minimize the active form, the others don't minimize. You can't select them, which means you can't use the minimize button.
I didn't developed the program, I was just adding new functionalities. I was wondering if there's any way around this, like, when you minimize the active form, all other minimize too.I'm kinda new to C#, and Visual Studio, so any help will be apreciated.

Simple, create a event handler for each form's on resize event. Then add this code to the event hander.

if (this.WindowState == FormWindowState.Minimized)
            {
                foreach (Form f in Application.OpenForms)
                {
                    f.WindowState = FormWindowState.Minimized;
                }
            }
            else if(this.WindowState == FormWindowState.Normal)
            {
                foreach (Form f in Application.OpenForms)
                {
                    f.WindowState = FormWindowState.Normal;
                }
            }

and if any of your forms support maximimization you will want to put an else in there for that. This simple loops through all the open forms in the app and sets them to the same state as the one that was minimized or restored.

Happy coding.

This article has been dead for over six months. Start a new discussion instead.