关闭窗体

protected override void WndProc(ref Message m)
        {
            const int WM_SYSCOMMAND = 0x0112;
            const int SC_CLOSE = 0xF060;
            if (m.Msg == WM_SYSCOMMAND && (int)m.WParam == SC_CLOSE)
            {
                //取消terbox1的验证事件
                this.textBox1.CausesValidation = false;
                ComDB.CloseConn();
                this.Close();
                return;
            }
            base.WndProc(ref m);
        }
  ////关闭窗体
原文地址:https://www.cnblogs.com/zzh1236/p/1389191.html