Solved

How to minimize my windows form to system tray?

Posted on 2008-09-30
2
1,031 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to check to see if datatable has headers or not 2 29
Android development question 2 37
Regular expression help 2 25
vb.net winforms sizing/resolution? 4 32
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

773 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