views:

74

answers:

1

Hi

I am wondering how do you re show a hidden windows form(in this case a windows mobile form but probably done the same way in windows forms).

Like Say I do this

Load Form 1 Click on a Button to Load Form 2 up Click on a button to load Form 3 up and hide Form 2. Click on a button to close Form 3 up and show Form 2.

I know how to hide and show them it is just hide() and show().

this is I am not sure how to call the Form2.show().

Form3 Form = new Form3()
Form.show();
this.close();

So this would make it show Form 2 would be closed then if I wanted to recreate it

Form2 Form = new Form2()
Form.show()
this.close()

So if I would do the above code then I would have 2 Form2 shown since I would have 2 Form2 objects.

A: 

Instead of creating new forms every time before showing them, try to create them once and save the reference to that Form (as a member in your class, for example). Then use that reference to show the form.

Tal Pressman
So what have a static property that holds the Form object?
chobo2
Nothing has it by default, but you can add it wherever it's appropriate (depending on the design of your application). You can even add a static Form2 member inside Form2...
Tal Pressman