将窗口关闭设为隐藏,然后又要在窗口关闭以前执行某个操作
我有两个窗口,MainForm和Form2,在MainForm中点击按钮弹出Form2
本人通过以下代码将Form2关闭改为隐藏,
private void Form2_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
this.Hide();
}
现在遇到的问题是,
我想在From2关闭的时候保存文件或者其他操作,
但程序永远不会执行CLosed()里的代码,
而Closing()里面也不能再执行保存代码,因为里面已经又了隐藏窗口的代码.
大家有没有好办法?!