如何在 vb.net 2008 中重新加载/刷新/重置表单

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20021965/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 17:17:34  来源:igfitidea点击:

How to reload/refresh/reset a form in vb.net 2008

vb.net

提问by Mark Anthony

Hi, I got this game it got multiple form so lets say Form1 is the main menu then the player presses start game. It goes to Form2 which is the game after game is finish it goes to Form3 then there will be a play again option where, it goes to the game again. I already use

嗨,我得到了这个游戏,它有多种形式,所以可以说 Form1 是主菜单,然后玩家按下开始游戏。它进入Form2,这是游戏结束后的游戏,它进入Form3,然后将有一个再次播放选项,它再次进入游戏。我已经在用

Dim f2 As New Form2

yeah it goes to the game but the game very weird and unstable I feel like some of the code didn't reset so how do I do this?

是的,它进入游戏,但游戏非常奇怪和不稳定我觉得有些代码没有重置,所以我该怎么做?

回答by BaeFell

Dim f2 As New Form2
Form2.Show()
Me.Close()

That should reset Form1

那应该重置Form1

Dim f3 As New Form3
Form3.Show()
Me.Close()

That will reset Form2

这将重置 Form2

Dim f1 As New Form1
Form1.Show()
Me.Close()

That will reset Form3 and return to Form1

这将重置 Form3 并返回到 Form1

回答by MTS

Set your application properties to :

将您的应用程序属性设置为:

Shutdown Mode : When Last Form Closes

关闭模式:当最后一个表单关闭时

When you move from Form1 to From2, just hide form1 using

当您从 Form1 移动到 From2 时,只需使用隐藏 form1

Form1.Hide()

Then in form2.load event, just close Form1

然后在 form2.load 事件中,关闭 Form1

Form1.close()