if (this..WindowState = FormWindowState.Minimized)
            {
                this.WindowState = System.Windows.Forms.FormWindowState.Normal;
                this.notifyIcon1.Visible = false;  
            }
            else
            {
                this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
                this.notifyIcon1.Visible = true; //窗体显示时,托盘图标不可见 
            }

解决方案 »

  1.   

    if (this.Visible == false)// 当窗体不可见时单击显示窗体
                {
                    this.Visible = true;
                    this.WindowState = System.Windows.Forms.FormWindowState.Normal;
                    this.notifyIcon1.Visible = true; //窗体显示时,托盘图标不可见 
                }
                else //Here
                if (this.Visible == true)// 当窗体可见时单击隐藏窗体
                {
                    this.Visible = false;
                    this.WindowState = System.Windows.Forms.FormWindowState.Normal;
                    this.notifyIcon1.Visible = true; //窗体显示时,托盘图标不可见 
                }