Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect when a windows form is being minimized?

Tags:

c#

winforms

I know that I can get the current state by WindowState, but I want to know if there's any event that will fire up when the user tries to minimize the form.

like image 846
Jorge Branco Avatar asked Jun 27 '09 14:06

Jorge Branco


People also ask

How do you check if a Windows form is already open and close it if it is?

Form fc = Application. OpenForms["UpdateWindow"]; if (fc != null) fc. Close(); fm.

How do you remove minimize and maximize button in Windows form?

To remove the minimize, maximize, and close buttons from your form, open your form in Design View. Under the View menu, select Properties. When the Properties window appears, set the "Control Box" property to "No". Now when the form is opened, the buttons will no longer appear in the top right of the form.

How do I open windows form in maximized?

In the Properties window, click the Shortcut tab (A). Locate the Run: section, and click the down arrow on the right side (red circle). In the drop-down menu that appears, select Maximized (B). Click Apply (C), and then click OK (D).


1 Answers

You can use the Resize event and check the Forms.WindowState Property in the event.

private void Form1_Resize ( object sender , EventArgs e ) {     if ( WindowState == FormWindowState.Minimized )     {         // Do some stuff     } } 
like image 112
Steve Dignan Avatar answered Sep 24 '22 10:09

Steve Dignan