Showing/Hiding the main form in C#
Posted
by
DazSlayer
on Stack Overflow
See other posts from Stack Overflow
or by DazSlayer
Published on 2011-01-15T20:50:49Z
Indexed on
2011/01/15
20:53 UTC
Read the original article
Hit count: 162
I am working on a program where clicking on a button on form1 will open form2. I will then hide form1 until form2 is closed. The problem I have is that I cannot get form1 to show after form2 closes. Any ideas on how to fix this?
try
{
Form1.ActiveForm.Hide();
AddGradeForm = new Form2(Form.NumberOfSelections);
AddGradeForm.ShowDialog();
MessageBox.Show(AddGradeForm.Result.ToString());
}
catch (Exception i)
{
Form1.ActiveForm.Hide();
AddGradeForm.Dispose();
AddGradeForm = new Form2(Form.NumberOfSelections);
AddGradeForm.ShowDialog();
MessageBox.Show(AddGradeForm.Result.ToString());
}
Form1.ActiveForm.Show();
ERROR: NullReferenceException was unhanded. Object reference not set to an instance of an object.
© Stack Overflow or respective owner