简体   繁体   English

VB.NET-为什么辅助表格关闭?

[英]VB.NET - Why is the secondary form closing?

In vb.net, whenever I click my button "ok", it also closes the second form? 在vb.net中,每当我单击我的按钮“确定”时,它还会关闭第二个表单吗? And please slap me if I have done a school boy error here. 如果我在这里犯了一个男生错误,请打我一巴掌。 I just do not understand what is going on. 我只是不明白发生了什么。

 Private Sub btOk_Click(sender As System.Object, e As System.EventArgs) Handles btOk.Click
       Close()
        Dim frmMainScreen As New frmMain

        frmMainScreen.Show()
 end sub 

You first have to show the new form, and then have to close the old form. 您首先必须显示新表格,然后必须关闭旧表格。

Default settings in your application is closing when last form closed. 上一个表单关闭时,应用程序中的默认设置正在关闭。 So if you close the actual form (which is the last i think) then your application closes complete. 因此,如果您关闭实际表单(我认为这是最后一个表单),那么您的应用程序将关闭完成。

I agree with @Alex you have to change the project properties (Application Tab => Shutdown mode => Select: "When last form closes") first, but also you need to change your code to be: 我同意@Alex,您首先必须更改项目属性(“应用程序选项卡=>关机模式=>选择:“当最后一个表单关闭时”) ,但还需要将代码更改为:

 Private Sub btOk_Click(sender As System.Object, e As System.EventArgs) Handles btOk.Click
        Dim frmMainScreen As New frmMain
        frmMainScreen.Show()
        Close()
 End Sub

Show the second form then close the previous one. 显示第二个表单,然后关闭上一个表单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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