关闭主窗体后无法显示Form2 [英] Not able to display Form2 after closing of mainform

查看:77
本文介绍了关闭主窗体后无法显示Form2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在从主表单显示登录表单时遇到问题.

代码:

I am facing issue with displaying login form from main form.

Code :

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       Dim frm2 As New Form2
       Me.Close()
       frm2.Show()
       Me.Show()
End Sub



这里的要求是mainform,必须在打开form2之前将其关闭,并且应该将其隐藏.如果它是隐藏的,则该项目根本不会关闭.当我使用me.close-时,它会放置对象,并且永远不会打开form2.
你能把我放下吗?

谢谢
Suresh Ch



Here the requirment is mainform has to be closed before opening the form2 and it should be hidden. if it''s hidden then the project is not closing at all. when I use me.close- it''s disposing the object and never opening the form2.
Could you please adivse me.

Thank you,
Suresh Ch

推荐答案

不要使用Me.Close-关闭表单并处理所有资源.如果这是主要形式,它还将终止应用程序.

而是使用Me.Hide()
Don''t use Me.Close - that closes the form and disposes of all the resources. If this is the main form, it will also terminate the application.

Instead, use Me.Hide()


Dim frm2 As New Form2
frm2.Show()
Me.Hide()


这篇关于关闭主窗体后无法显示Form2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆