I have an MDI application. One form is opened. From there a report button can be clicked, which opens another child form. currentReportSelection contains the new'ed up frmReport. I have a problem when frmReport is closed. Once the report button is clicked again, a disposed exception occurs on the reportForm.Show() line:
private void btnReports_Click(object sender, EventArgs e)
frmReport reportForm = currentReportSelection;
reportForm.MdiParent = this.MdiParent;
reportForm.WindowState = System.Windows.Forms.FormWindowState.Maximized;
The exception is:
Cannot access a disposed object.
Object name: 'frmReport'.
It always works fine on the first click but there after, I get the exception.
How can I fix this?