0

我有这个 MainForm 作为我的 MDI 父级。当我打电话给我的 MDIChild 时,它通常会出现一次。我关闭 MDIChild 并再次打开它的时间。它有一个未处理的 ObjectDisposedException(无法访问已处置的对象。)

private void BtnUserPanel_Click(object sender, EventArgs e)
{
    FormAccounts fa = new FormAccounts();
    fa.MdiParent = this;
    fa.Show(); //ObjectDisposedException was unhandled
}

我将如何捕获此错误,以便当我关闭我的 MDIForm 并再次打开时,它会再次显示我的 MDIForm 而没有此 ObjectDisposedException。

当我尝试关闭 MDIChildren 然后再次打开 MDChildren 时,我从 MDI Parent 堆栈跟踪中得到了这个:

未经处理的异常:无法访问已处置的对象。对象名称:'FormAccounts'。在 System.Windows.Forms.Control.CreateHandle() 在 System.Windows.Forms.Form.CreateHandle() 在 System.Windows.Forms.Control.get_Handle() 在 System.Windows.Forms.Form.SetVisibleCore(布尔值)在 System.Windows.Forms.Control.Show() 在 System.Windows.Forms.COntrol.Show() 在 Lendmattic.UI.FormMain.BtnUserPanel_Click(Object sender, EventArgs e) 在 FormMain.cs:line71

4

0 回答 0