1. Set form Properties Showintask=false
2. Add the NotifyIcon control Notifyicon1, adding an icon icon for the property icon of the control Notifyicon1.
3. Add form Minimize event (you need to add an event reference first):
//this.sizechanged+=newsystem.eventhandler(this.form1_sizechanged);
//上面一行是主窗体initializecomponent()方法中需要添加的引用
privatevoidform1_sizechanged(objectsender,eventargse)
{
if(this.windowstate==formwindowstate.minimized)
{
this.hide();
this.notifyicon1.visible=true;
}
}
4. Add Click Icon Event (first need to add event reference):
privatevoidnotifyicon1_click(objectsender,eventargse)
{
this.visible=true;
this.windowstate=formwindowstate.normal;
this.notifyicon1.visible=false;
}
5. You can add the right button menu to NotifyIcon:
Drag a ContextMenu control contextmenu1 the main form, click the Control, add a menu to the context menu, and select Contextmenu1 as the context menu in the ContextMenu behavior of the notifyicon1.
(You can add behavior to the submenu)