this blog contains information for .net and sql stuffs. You can find various tips and tricks to overcome problem you may be facing in ...

Friday, May 14, 2010

Show Tray Icon for your application In .net.

In our daily life we see many applications that run in background; we can see them in system tray. Let me tell you, System Tray at the bottom right corner of the screen which shows datetime, network connection, firewall or any programs that running but not showing in taskbar.

We can also put our application’s Icon in system Tray. To achieve it, just go through below steps.
-->Drag NotifiyIcon to your main form (Form which is going to run at start up)

-->Wire up event for form’s resized and add code as...
if(this.WindowState == FormWindowState.Minimized)
this.Hide();

-->Now we have two choice to again show our application in taskbar, either simply clicking on notifyIcon just call this.Show() or add a context menu.

-->This context menu have one or more options like restore application, close application etc.

NotifyIcon control has Icon property to show Icon of your application, and ContextMenuStrip to set contextmenu when you right click on it at system tray.

No comments: