窗体在关闭时候调的是OnClosing 方法
我在给OnClosing 重写时里面什么也不做
protected override void OnClosing(CancelEventArgs e)
{
// base.OnClosing(e);
}
在关闭窗体的时候居然也会关闭 ,不知道内在。请了解的人,指点一下!!!!!!
我在给OnClosing 重写时里面什么也不做
protected override void OnClosing(CancelEventArgs e)
{
// base.OnClosing(e);
}
在关闭窗体的时候居然也会关闭 ,不知道内在。请了解的人,指点一下!!!!!!
也就是:
点击关闭窗体->先做事件代理要做的事情->再关闭窗体。
所以关闭窗体是肯定要做的,你在OnClosing里什么也不写,表示你没有什么“额外”要它做的事情,但是最后一步关闭窗体还是跑不了的。
{
CancelEventArgs e = new CancelEventArgs();
OnClosing(e); //<--- if (!e.Cancel)
{
OnClosed(EventArgs.Empty); //<---
// DestroyMyself();
// Dispose();
}
}
事件的意思是 窗体通知你 我现在发生了什么事情
如果你不修改E.CANCEL为true
那他会继续执行后面的代码