using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace CloseWindow
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }        private void button1_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("您确定要关闭", "关闭", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
            {
                this.Validate()
                this.Close();
            }
        }
    }
}
-----------
测试通过看来是以下两句的问题,查查看
this.下载文章记录BindingSource.EndEdit();
this.下载文章记录TableAdapter.Update(this.日常事务日志DataSet.下载文章记录);
Good Luck!
Tony!

解决方案 »

  1.   

    我用下面这段代码实现了:
           private void Form1_FormClosing(object sender, FormClosingEventArgs e)
            {
                if (MessageBox.Show("是否要保存数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1 ) != DialogResult.No  )
                {
                    this.Validate();
                    this.下载文章记录BindingSource.EndEdit();
                    this.下载文章记录TableAdapter.Update(this.日常事务日志DataSet.下载文章记录);
                }
            }谢谢!
      

  2.   

    你用 cancel=False; 绝对可以关闭。试试看