C# Winform 窗体关闭事件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1179661/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 10:10:35 来源:igfitidea点击:
Winform form closed event
提问by Saif Khan
I have 2 forms, Main and Child. When a button is clicked on the Main form, the Child form is loaded. Can I catch from the Main form, when the Child form is closed by subscribing to the closed event of the child form?
我有 2 个表格,Main 和 Child。单击主窗体上的按钮时,会加载子窗体。当通过订阅子窗体的关闭事件关闭子窗体时,我可以从主窗体捕获吗?
采纳答案by Fredrik M?rk
Yes you can, it's pretty straightforward:
是的,你可以,这很简单:
private void LoadChildForm_Click(object sender, EventArgs e)
{
ChildForm form = new ChildForm();
form.FormClosed += new FormClosedEventHandler(ChildFormClosed);
form.Show();
}
void ChildFormClosed(object sender, FormClosedEventArgs e)
{
// do something useful
}