Showing/Hiding the main form in C#
- by DazSlayer
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.