繁体中文
设为首页
加入收藏
当前位置:.Net技术首页 >> Windows开发 >> 捕捉窗口关闭事件(转贴)

捕捉窗口关闭事件(转贴)

2004-10-01 08:26:10  作者:  来源:互联网  浏览次数:78  文字大小:【】【】【
简介:public class whoisresult : System.Windows.Forms.Form { ............................. private bool TangSeng = false; } private void InitializeComponent() { ............................. this.Closin...
关键字:窗口 事件

public class whoisresult : System.Windows.Forms.Form

{

.............................

private bool TangSeng = false;

}

private void InitializeComponent()

{

.............................

this.Closing += new CancelEventHandler(this.whoisresult_Cancel);

}

protected void whoisresult_Cancel(object sender,CancelEventArgs e)

{

if(!TangSeng)

{

e.Cancel = true;

TangSeng = true;

MessageBox.Show("悟空,你也太调皮了,每次都要我提醒你,诶~~~");

}

else

{

e.Cancel = false;

MessageBox.Show("这次总算学乖了");

}

}

窗体关闭事件可以取消,通过设置cancel属性

责任编辑:admin
相关文章