关闭窗口不止一次 [英] Closing window is occurring more than one time

查看:84
本文介绍了关闭窗口不止一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

多次关闭窗口发生



我尝试过:



Multiple times closing window occurring

What I have tried:

private void Form2_FormClosing(object sender, FormClosingEventArgs e)
{
    DialogResult d = MessageBox.Show("Do u want to close application", "Exit", MessageBoxButtons.YesNo);
    if (d == DialogResult.Yes)
    {
        Application.Exit();
    }
    else if(d==DialogResult.No)
    {
        e.Cancel = true;
    }
}

推荐答案

调试将解释原因...设置断点 Form2_FormClosing 事件,每次到达断点时都会查看堆栈跟踪,您会看到原因。
Debugging will explain why... Set a breakpoint in the Form2_FormClosing event, look at the stack trace each time you hit the breakpoint and you will see why.


这篇关于关闭窗口不止一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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