donie
donie

Reputation: 29

What is different about this.Hide() and this.WindowState = FormWindowState.Minimized; in C#

What the difference between the following:

  1. this.Hide();
  2. this.WindowState = FormWindowState.Minimized;

Upvotes: 2

Views: 1050

Answers (2)

keysl
keysl

Reputation: 2167

This is only one difference I find in those two.

   this.Hide();

Will hide the application and it will not show in the taskbar hence

this.WindowState = FormWindowState.Minimized;

Will only minimized the app in the taskbar.

Upvotes: 0

Jon Hanna
Jon Hanna

Reputation: 113232

If a form is minimised it can be maximised or restored. It is still considered visible (perhaps on the task bar), but not within the set of windows currently being displayed.

If it is hidden, then it cannot be seen at all. Hide() is in fact a shortcut for Visible = false and is exactly the same in the case of a child control.

Consider how some applications have a "hide on minimise" (and sometimes "hide on close") option, especially if they are often accessed through notification icons. If this option is not set then (as per most programs with a UI) if you minimise the window, it's still on the task bar. If it is set then when you minimise the window if disappears from the task bar. In this latter case it is minimised and hidden.

Upvotes: 2

Related Questions