C#怎样点击窗体的关闭时让窗体隐藏,显示在系统托盘里?

解决方案 »

  1.   

    处理窗体的Closing事件
    在事件中添加
    e.Cancel = true;
    this.Hide();
      

  2.   

     private void FormClosing(object sender, FormClosingEventArgs e)
     {
           if (e.CloseReason == CloseReason.UserClosing)
           {
                //User clicks the close button
                e.Cancel = true;
                Hide();
           }else
           {
               //you can do whatever you like 
               //for example Exit();
           } }
      

  3.   

                    this.ShowInTaskbar = false; //不显示在系统任务栏
                    this.notifyIconMain.Visible = true; //托盘图标可见
      

  4.   

    补充
     this.WindowState = FormWindowState.Minimized; //窗体最小化
      

  5.   

    this.hide.
    或者 this.空间名.visible=false;
      

  6.   

     private void frmMain_Closing(object sender, System.ComponentModel.CancelEventArgs e)
            {
               this.notifySys.Visible=true;        
                this.Hide();   
                e.Cancel = true;  
            }
      

  7.   

    this.hide();
    or
    this.Visible=false
      

  8.   

    this.hide(); 
    没有关闭啊。只是你看不见而已