Cannot access a disposed object. Object name: 'formMain'

时间:2018-02-03 07:36:59

标签: c#

I'm new for C#. My MDI application has some children forms. these forms need to visible and load time to time. when I load a children form second time by using Show(), the above exception is coming. when I load a form first time I use Close() to close the loaded form. Buttons are in MDI form.Please help to solve this issue.

My some code snippet is bellow,

Form closingForm = new Form();
private void button1_Click(object sender, EventArgs e)
{
 closingForm.Close();
 closingForm = form1;
 closingForm.Show();   
}
private void button2_Click(object sender, EventArgs e)
{
 closingForm.Close();
 closingForm = form2;
 closingForm.Show();
}

0 个答案:

没有答案