1. Add a policyicon control to form.
2. Place the 87. ico icon in the \ bin \ Debug directory.
Code
Using System;
Using System. Collections. Generic;
Using System. ComponentModel;
Using System. Data;
Using System. Drawing;
Using System. Text;
Using System. Windows. Forms;
The namespace minimizes the program to the system tray
{
Public partial class Form1: Form
{
Public Form1 ()
{
InitializeComponent ();
}
Private void Form1_Load (object sender, EventArgs e)
{
This. policyicon1 = new System. Windows. Forms. policyicon (this. components );
Policyicon1.icon = new Icon ("87.ico"); // specify an Icon
Policyicon1.visible = false;
Policyicon1.click + = new System. EventHandler (this. policyicon#click );
This. SizeChanged + = new System. EventHandler (this. Form1_SizeChanged );
}
Private void Form1_SizeChanged (object sender, EventArgs e)
{
If (this. WindowState = FormWindowState. Minimized) // minimize
{
This. ShowInTaskbar = false;
This. policyicon1.visible = true;
}
}
Private void policyicon#click (object sender, EventArgs e)
{
If (this. WindowState = FormWindowState. Minimized)
This. WindowState = FormWindowState. Normal;
This. Activate ();
This. policyicon1.visible = false;
This. ShowInTaskbar = true;
}
}
}