Winforms Minimize to System Tray

19 May 2006

Best article I've seen on this is at When you minimize your application, it actually fires a resize event on the form, so you can attach code to the resize event to handle this:

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

You add a NotifyIcon control to your form, and that creates the little icon on the system tray. There's a doubleclick event for that, and just handle it with this code:

private void notifyIcon1_DoubleClick(object sender,
System.EventArgs e)
WindowState = FormWindowState.Normal;

And there you go. Thanks to