// this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged);
// The above 1 The line is the main form InitializeComponent() The reference to be added to the method
private void Form1_SizeChanged(object sender, EventArgs e)
{
if (this.WindowState==FormWindowState.Minimized)
{
this.Hide();
this.notifyIcon1.Visible=true;
}
}
. Add click icon event ( You first need to add an event reference ) :
private void notifyIcon1_Click(object sender, EventArgs e)
{
this.Visible = true;
this.WindowState = FormWindowState.Normal;
this.notifyIcon1.Visible = false;
}
. Can you give notifyIcon Add right click menu:
Drag into the main form 1 a ContextMenu controls contextMenu1 , click the control in the context menu to add a menu, notifyIcon1 the ContextMenu Behavioral selection contextMenu1 As a context menu.
( You can add behavior to a submenu )