John
But then don't I have two versions of form1 in memory?
If I understand correctly, this is what I have:
On Form1:
private void button1_Click(object sender, System.EventArgs e)
{
Form2 myForm2 = new Form2();
myForm2.Show();
this.Hide();
}
On Form2:
private void Form2_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
Form1 myForm1 = new Form1();
myForm1.Show();
}
This displays a Form1 when Form2 closes but it is a new Form1. The original
Form1 remains hidden so now I have 2 Form1s in memory.
Is this correct?
"John M Deal" <jo******@necessitysoftware.com> wrote in message
news:uW**************@tk2msftngp13.phx.gbl...
For this I'd setup Form2 with a constructor that takes a generic form
parameter, then in the closing event of Form2 I'd set the form that was
passed in as part of the constructor to be visible. This will allow you
to use any form as the parent of Form2 (in case it happens to be reusable
elsewhere). Hope this helps.
Have A Better One!
John M Deal, MCP
Necessity Software
Dave wrote: I have a button on Form1 that hides the form and displays Form2:
Form2 myForm2 = new Form2();
myForm2.Show();
this.Hide();
After I do some work in Form2 I want to close it and redisplay Form1. I
can close the form with:
this.Close();
But how to I invoke the Show method of Form1? IOW how do I make Form1
visible again?
What I want to call while closing Form2 is "Form1.Show(); " but this
throws an object reference error.
I don't need to instantiate a new Form1. I just need to reference the one
that already exists and make it visble.
Arrrgh!!!! Can someone provide some insight?