虽然退出表格我必须点击两次是消息框的按钮 [英] While Exit Of The Form I Have To Click Two Times Yes Button Of Message Box

查看:63
本文介绍了虽然退出表格我必须点击两次是消息框的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private void Admin_FormClosing(object sender, FormClosingEventArgs e)
{
    DialogResult dialog = MessageBox.Show("Do you really want to close the      Program?", "Exit", MessageBoxButtons.YesNo);
    if (dialog == DialogResult.No)
    {
        e.Cancel = true;


    }
    else if (dialog == DialogResult.Yes)
    {

        e.Cancel = false;
        Application.Exit();
    }
}

推荐答案

取出'else子句:你的调用Application.Exit正在获取猴子confused。
Take out the 'else clause: your calling Application.Exit is getting the monkey confused.
private void Admin_FormClosing(object sender, FormClosingEventArgs e)
{
    DialogResult dialog = MessageBox.Show("Do you really want to close the      Program?", "Exit", MessageBoxButtons.YesNo);
    
    if (dialog == DialogResult.No) e.Cancel = true;
}


这篇关于虽然退出表格我必须点击两次是消息框的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆