tonyy
tonyy

Reputation: 27

Showing a hidden form (using this.Hide()) from another form

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.

Upvotes: 1

Views: 163

Answers (1)

Madushan
Madushan

Reputation: 7458

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();

Upvotes: 3

Related Questions