简体   繁体   English

如何从Form4移回Form1?

[英]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: 我已经很幸运了:

Wizard Form Implementation 向导表单实施

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.

相关问题 如何将对象从form1传递给form2并返回到form1? - How do you pass an object from form1 to form2 and back to form1? 如何从form1的form1调用事件? - how to call a event from form1 in form? 数据在从 Form2 发送回 Form1 之前验证 - Data validate before send back from Form2 to Form1 如何将bool变量从form2传递回form1? - How do I pass a bool variable from form2 back to form1? C#如何将form3的值传递回form1 - C# how to pass the value of form3 back to form1 当我/拖动/移动新窗体后面的form1使其同时与form1一起移动时,我该如何做? - How can i make that when i /drag/move form1 around the new form behind it will move with form1 on the same time? 我知道如何将信息从Form1发送到Form2,但是如果数据包含在列表中,我该如何进行编辑并将其发送回去 <T> 在Form1中? - I know how to send information from Form1 to Form2, but how do I edit it and send it back if the data is contained in a List<T> in Form1? 如何从form1中删除背景图像? - How to remove backgroundimage from form1? 我做到了,form1将缓慢向左移动。 如何使它从屏幕中心开始? - I did that the form1 will move slowly to the left. How can i make that it will start from the center of the screen? 如何在C#Winforms中以编程方式移动Form1中的所有标签 - How to move all labels in Form1 programmatically in C# Winforms
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM