//首先要設置notifyIcon屬性:Icon設置ico圖標,不然在系統托盤無圖標顯示
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
this.WindowState = FormWindowState.Normal;
//若使用Hide()時,要用Show()方法顯示窗體
}
private void MainForm_Resize(object sender, EventArgs e)
{
this.ShowInTaskbar = this.WindowState != FormWindowState.Minimized;//最小化時不在任務欄顯示
//或者以下
if (this.WindowState == FormWindowState.Minimized) Hide();//最小時隱藏
}
//設置系統托盤右擊菜單拖控件ContextMenuStrip, 在notifyIcon的ContextMenuStrip屬性選擇此contextMenuStrip控件。contextMenuStrip可增長菜單項點擊事件