2

Possible Duplicate:
Restore WindowState from Minimized

I have window which is normally hidden in the tray bar.

Then I want to show it if it was hidden, and bring to the front.

If it's already opened, I want to just bring it to front.

And if it's minimized to task bar, then I want to expand it and bring to front.

Now I have this in my show method:

this.Show();
this.Activate();
this.ShowInTaskbar = true;
this.TopMost = true;
this.Focus();

But if it's minimized it will not expand.

How to fix this?

Community
  • 1
  • 1
Ksice
  • 3,277
  • 9
  • 43
  • 67
  • I have edited your title. Please see, "[Should questions include “tags” in their titles?](http://meta.stackexchange.com/questions/19190/)", where the consensus is "no, they should not". – John Saunders Oct 05 '12 at 13:32

3 Answers3

3

Try adding this.WindowState = FormWindowState.Maximized

For full details of the FormWindowState enum, see here

Mark Sherretta
  • 10,160
  • 4
  • 37
  • 42
2

If it is minimized, you will have to restore the window using the WindowState property.

 this.WindowState = FormWindowState.Maximized; // To maximize
 this.WindowState = FormWindowState.Normal; // To restore
Bob.
  • 3,894
  • 4
  • 44
  • 76
2
if (this.WindowState == FormWindowState.Minimized)
    this.WindowState = FormWindowState.Normal;    

this.Show();
this.Activate();
this.ShowInTaskbar = true;
this.TopMost = true;
this.Focus();
Landern
  • 374
  • 2
  • 5