在表单关闭后从特定上下文运行代码? [英] Running Code From A Particular Context After A Form Closes?
本文介绍了在表单关闭后从特定上下文运行代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在此处创建的表单关闭后在此上下文中运行一些代码.
I want to run some code in this context after the form created here closes.
Form1 Form1 = new Form1();
Form1.Show(); //<-After this closes, I want to run code from this context, using ShowDialog() is not an option
推荐答案
只需注册Form
void MyClosingEvent(object o, FormClosingEventArgs args)
{
}
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
Form1 form1 = new Form1();
form1.FormClosing += new FormClosingEventHandler(MyClosingEvent);
//Or if you have C# 2 or higher:
//form1.FormClosing += MyClosingEvent;
这篇关于在表单关闭后从特定上下文运行代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文