简体   繁体   中英

how to move back from form4 to form1?

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM