notifyIcon控件最小化图标

 private void frmMain_Load(object sender, EventArgs e)
        {
            //最小化到托盘
            this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
            notifyIcon1.Icon = new Icon("Main.ico");
            notifyIcon1.Visible = false;
            notifyIcon1.ContextMenuStrip = this.contextMenuStrip1;
            notifyIcon1.DoubleClick += new EventHandler(notifyIcon1_DoubleClick);

       }

  /// <summary>
        /// 最小化到托盘
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmMain_Resize(object sender, EventArgs e)
        {
            if (this.WindowState == FormWindowState.Minimized)
            {
                notifyIcon1.Visible = true;
                this.ShowInTaskbar = false;
            }
        }
        void notifyIcon1_DoubleClick(object sender, EventArgs e)
        {
            if (this.WindowState == FormWindowState.Minimized)
            {
                this.WindowState = FormWindowState.Maximized;
                this.Activate();
                this.notifyIcon1.Visible = false;
                this.ShowInTaskbar = true;
            }
        }

原文地址:https://www.cnblogs.com/Iyce/p/2738662.html