How do I minimize a WinForms application to the notification area?

I want to minimize a C# WinForms app to system tray. I've tried this:

Having the application minimize to the system tray when button is clicked?. The first time I minimize it, it's nowhere to be found on the screen - taskbar/above taskbar/tray.

If i hit alt tab, I can see my app there; if I alt tab into it and minimize it again, it shows up above the taskbar:

What am I doing wrong?


What about the option of hiding the form when minimized then showing once you click on the tray icon?

In the form resize event, do the check there and hide the form

   private void Form_Resize(object sender, EventArgs e)
        if (WindowState == FormWindowState.Minimized)

Then when clicking on the taskbar icon just restore it.

    private void notifyIcon_Click(object sender, EventArgs e)
        this.WindowState = FormWindowState.Normal;

You need to add a NotifyIcon to your form. You can then use the Click event of the NotifyIcon to have it set the Visible property on your Form to true again.

You need to add an icon on NotifyIcon for it to be visible.

You have to set the property ShowInTaskbar = true of your Form. It automatically minimizes to the task bar.

Need Your Help

Difference between `Optional.orElse()` and `Optional.orElseGet()`

java java-8 optional

I am trying to understand the difference between the Optional<T>.orElse() and Optional<T>.orElseGet() methods.

Activate a virtualenv via fabric as deploy user

python virtualenv fabric automated-deploy

I want to run my fabric script locally, which will in turn, log into my server, switch user to deploy, activate the projects .virtualenv, which will change dir to the project and issue a git pull.