如何知道usercontrol(form)是否关闭? [英] How to know usercontrol(form) is closing or not?
本文介绍了如何知道usercontrol(form)是否关闭?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
如何知道usercontrol(form)是否关闭?
让我知道
我的代码
hi all
How to know usercontrol(form) is closing or not?
let me know
my code
//pageload
this.ParentForm.FormClosing += new FormClosingEventHandler(ParentForm_FormClosing);
void ParentForm_FormClosing(object sender, FormClosingEventArgs e)
{
UpdateAll();
}
它不起作用
在此先感谢
it''s not working
Thanks in advance
推荐答案
对我来说效果很好:
It works fine for me:
void ParentForm_FormClosing(object sender, FormClosingEventArgs e)
{
Console.WriteLine("Form closing");
}
private void UserControl1_Load(object sender, EventArgs e)
{
ParentForm.FormClosing += new FormClosingEventHandler(ParentForm_FormClosing);
}
检查是否已为控件连接了Load事件处理程序.
Check that you have hooked up the Load event handler for your control.
这篇关于如何知道usercontrol(form)是否关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文