Make System Tray Based Application in .NET

Contributor Icon Contributed by johnnythawte  
Tag Icon Tagged: C programming  

Creating an application that lives in the system tray is easy, but it is not entirely obvious how to do so in Visual Studio. This recipe will show you the steps.


1) First, create a new Windows Application project in Visual Studio.NET. This can be either Visual Basic or C#

2) Drag a Notifyicon control and a ContextMenu control from the toolbox onto the form.

3) Click on the NotifyIcon control that you just added, and set the Icon property to whatever icon you want your application to have.

4) Set the ContextMenu property of the Notifyicon to the context menu that you added to your project.

5) Right click on the Context Menu control, and select Edit. Since this menu will be the right-click menu for your tray icon, you will want to add the items that the user will see. Make sure to add an Exit menu item.

6) Double click the Exit menu item, and add the following code:this.Close();

7) Now for the important settings. Click on the form, and go to the Properties window. Set the following settings:
FormBorderSize: Fixed Tool Window
WindowState: Minimized
Opacity: 0%
ShowInTaskbar: False

The key thing to remember is that the default form is not to be used for application functionality, it is only used as the hidden background window. If you want to create a new window, you can just add another form to your application.

 

13 Comments -


  1. Amrita said on December 1, 2008

    That is cool!!!

  2. 0p1e said on April 22, 2009

    Awesome, just what I needed.
    Thanks!

  3. Tom said on May 8, 2009

    Nice job- thanks for the info!

  4. TY said on July 4, 2009

    THANKS!

  5. hacker said on October 26, 2009

    Thanks! Works perfect!

  6. Anonymous said on April 28, 2010

    thank you.

  7. None said on May 4, 2010

    Just what I needed, much appreciated.

  8. Abcd said on July 6, 2010

    thank u very much..very good one

  9. Seth Adam Davis said on March 1, 2011

    Wow. Great tut! Easy and straightforward.

  10. hahahut said on March 1, 2011

    Awesome! Just what I need!

  11. John Bryntze said on April 2, 2011

    Even I could do it with this description, then anyone can, thanks a lot, this is super cool

  12. ddonate said on September 21, 2011

    Thanks a lot!! Easy & complete…

  13. Dave said on December 15, 2011

    Thanks so much, I can’t believe how simple it is to get a tray app up and running.

 

RSS feed for comments on this post. TrackBack URL

Leave a comment -