我想做的很简单,只是希望能够在关闭表单后运行一些代码。

Form1 f = new Form1();
f.Show();
f.formClosing ... <- I just want to run code from this context once this form has been closed

最佳答案

{
    Form1 f = new Form1();
    f.FormClosed += new FormClosedEventHandler(f_FormClosed);
    f.Show();
}

void f_FormClosed(object sender, FormClosedEventArgs e)
{
    // Do stuff here
}

关于c# - 将代码中的表单关闭事件添加到特定对象实例?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5982418/

10-13 08:43