如何屏蔽关闭按钮

来源:互联网 发布:简易论坛友情源码 编辑:程序博客网 时间:2024/04/28 21:53

//如何屏蔽关闭按钮

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (DataSetChanged())
            {
                if (DialogResult.Yes == MessageBox.Show("尚有修改了,但未提交的数据,是否提交后再关闭?", "友情提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                {
                    e.Cancel = true;
                    tsbSubmit_Click(null, null);
                    return;
                }
            }
        } 

private void tsbSubmit_Click(object sender, EventArgs e)
        {

//do anything you need to submit

        }