tags:

views:

53

answers:

3

hi

in my C# program i Moves from one screen to another like this:

Form G = new Screen1();
G.ShowDialog();
G.Dispose();
G.Close();

i move from screen1 --> screen2 --> screen3 --> screen4

when i in screen4 and i want to go back to screen1 - if i'll write this.close()

i'll go only to screen3

how to go back from screen4 to screen1

thank's in advance

A: 

You can implement this functionality using a Quequ which maintaind a list of opened forms and since Quequ is a Fifo, you will get the first form object when you call Dequequ.

saurabh
A: 

Since all your form are modal (ShowDialog), adding a this.Close(); after each call to Dispose on the child screen will close the direct parent:

Form G = new Screen1();
G.ShowDialog();
G.Dispose();
G.Close();
this.Close();

But you have to do this on screen2 and screen3.

You could also implement a class that will manage the opening and closing of child screens instead of doing it in each screen. This approach works well if you can chain the screens as some sort of wizard.

Johann Blais
but with this solution i cant go back from form3 to form2 - or from form4 to form3....
Gold
+1  A: 

You should consider using a Wizard style approach. There are a number of articles on how to do this on codeproject.com. I've had luck with this one:

Wizard Form Implementation

Jay Riggs