1
votes

I've hidden a form Form1 and have shown a new form Form2 using the following code:

    form_Form2 f = new form_Form2();
    this.Hide();
    f.Show();

where this == Form1. How do I then make Form1 visible again from Form2? I do not want to create a new instance of Form1, I just want to make it show up again because the this.Hide() function keeps the data on the form instead of fully closing it.

1
Subscribe the FormClosing event to know that the form is about to close. Or use ShowDialog(). - Hans Passant

1 Answers

3
votes

Form2 will need a reference to Form1

form_Form2 f = new form_Form2();
f.OtherForm = this;
this.Hide();
f.Show();

You will have to add OtherForm property. Then later in Form 2

OtherForm.Show();