Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有两个名为:
Form1 & Form2
在Form1中,我在按钮单击事件中有一个带有此代码的按钮:
Form2.Show() Me.Dispose()
当我单击此按钮时,它会同时关闭两个表单。
我只需要关闭Form1。
您的项目设置可能设置为在启动表单关闭时终止应用程序。将选项更改为“最后一个表单关闭”应该可以解决此问题。
“项目”菜单 -> 'YourApp' 属性... -> 应用程序选项卡
找到:“关机模式”
从“启动表单关闭时”更改->“最后一个表单关闭时”
不要给Dispose自己打电话。Me.Close()在相同的上下文中尝试。
Dispose
Me.Close()