我们有一个名为Notes
的MDI子表单,它以这种方式打开另一个表单:
private void OpenRecentlyBilled()
{
if (Application.OpenForms.OfType<RecentlyBilled>().Count() == 1) return;
Action<string, Form> lookupAction = (anoncode, form) =>
{
Lookup(anoncode);
};
var F = new RecentlyBilled(lookupAction);
F.Show(this);
}
在Notes
结算活动中,我们首先检查该RecentlyBilled
表单是否已打开,如果是,请关闭它:
private void Notes_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = false;
if (Application.OpenForms.OfType<RecentlyBilledCases>().Count() > 0)
{
foreach (RecentlyBilled f in Application.OpenForms.OfType<RecentlyBilled>())
{
f.Close();
}
}
}
RecentlyBilled
表单关闭但Notes
MDI子表单保持打开状态,直到再次单击其[X]按钮。
这是因为RecentlyBilled
表单尚未处理,并且引用了打开它并将动作传递给它的Notes
表单?