[英]how to move back from form4 to form1?
in my C# program i Moves from one screen to another like this: 在我的C#程序中,我从一个屏幕移动到另一个屏幕,如下所示:
Form G = new Screen1();
G.ShowDialog();
G.Dispose();
G.Close();
i move from screen1 --> screen2 --> screen3 --> screen4 我从screen1-> screen2-> screen3-> screen4移动
when i in screen4 and i want to go back to screen1 - if i'll write this.close()
当我在screen4中并且我想回到screen1时 -如果我要编写
this.close()
i'll go only to screen3 我只会去screen3
how to go back from screen4 to screen1 如何从screen4返回到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.
在codeproject.com上有许多有关如何执行此操作的文章。 I've had luck with this one:
我已经很幸运了:
Since all your form are modal (ShowDialog), adding a this.Close();
由于您的所有表单都是模式表单(ShowDialog),因此添加
this.Close();
after each call to Dispose on the child screen will close the direct parent: 在子屏幕上每次调用Dispose后,将关闭直接父级:
Form G = new Screen1();
G.ShowDialog();
G.Dispose();
G.Close();
this.Close();
But you have to do this on screen2 and screen3. 但是您必须在screen2和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.
如果您可以将屏幕链接为某种向导,则此方法效果很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.