Solved

How to minimize my windows form to system tray?

Posted on 2008-09-30
2
1,028 Views
Last Modified: 2012-05-05
How to minimize my windows form to system tray?

I have a standalone application developed in Dot net 3.0. When the Minimize button is pressed (it is in running mode), it should automatically go to system tray (it should run in back ground and icon should be there in system tray) and when the user clicks on the icon in system tray, it should display its Main Form. How to achieve this? Can anyone supply me the code for this?
0
Comment
Question by:GouthamAnand
2 Comments
 
LVL 15

Accepted Solution

by:
angus_young_acdc earned 500 total points
ID: 22603340
Add a NotifyIcon to your form. Set the default Visible property to be false.

Add a Form_Resize event handler to the form.

private void Form1_Resize(object sender, System.EventArgs e)
{
      if(this.WindowState == FormWindowState.Minimized)
      {
            this.Visible = false;
            notifyIcon1.Visible = true;
      }
}

Then add an event handler to the NotifyIcon (usually double click) with this code:

this.Visible = true;
notifyIcon1.Visible = false;

And the following sites should help:
http://www.codeguru.com/Csharp/.NET/net_general/tipstricks/article.php/c6933/
http://www.developer.com/net/csharp/article.php/3336751
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp06102002.asp

Credit to EE for the above.
0
 

Author Closing Comment

by:GouthamAnand
ID: 31501476
Thank you..
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How can I use SQL Stored Procedure to return FedEx Zone 17 41
Error in page 3 44
Problem to open text file 11 66
C# parent child form 5 12
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

948 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now