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
the形式关闭,但是
RecentlyBilled
mDi子形式保持打开状态,直到第二次单击其[x]按钮。 这是因为
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
集合引起的:
RecentlyBilled
Notes
是一个简单的解决方案:
OpenForms