1. Set form attribute showintask = false
2. Add the policyicon control policyicon1 to add an icon for the property icon of the control policyicon1.
3. Add a form minimization event (first add event reference ):?
// This. sizechanged + = new system. eventhandler (this. form1_sizechanged );
// The above line is the reference to be added in the main form initializecomponent () method
Private void form1_sizechanged (Object sender, eventargs E)
{
If (this. windowstate = formwindowstate. Minimized)
{
This. Hide ();
This. policyicon1.visible = true;
}
}
4. Add a click icon event (you must first add an event reference ):
Private void policyicon#click (Object sender, eventargs E)
{
This. Visible = true;
This. windowstate = formwindowstate. normal;
This. policyicon1.visible = false;
}
5. You can right-click policyicon to add a menu:
In the main form, drag a contextmenu control contextmenu1, click the control, and add a menu in the context menu. In the contextmenu action of notifyicon1, select contextmenu1 as the context menu.
(You can add actions in the sub-menu)