如何从当前表单打开另一个表单?
我们的第一个表单是登录表单。登录后如何打开下一个表单?
Our first form is the LOG IN form..how can I open to the next form after logging in?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我们的第一个表单是登录表单。登录后如何打开下一个表单?
Our first form is the LOG IN form..how can I open to the next form after logging in?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
在您的登录表单中,我假设您在按钮控件的 Click 事件方法内执行验证。因此,您将得到如下内容:
此代码的两个有趣的功能是:
Show
方法,您可以在要显示的表单对象上调用该方法。在这种情况下,它可能是您的主窗体 - 将
MainForm
替换为它所调用的任何名称。Unload
语句,用于关闭并销毁指定的表单。在本例中,
Me
指的是登录表单,因为您已经完成了它。In your log-in form, I assume you perform your validation inside of the
Click
event method for a button control. So you would have something like:The two interesting features of this code are:
The
Show
method, which you call on the form object that you want to show.In this case, it will probably be your main form—replace
MainForm
with whatever it is called.The
Unload
statement, which closes and destroys the specified form.In this case,
Me
refers to the login form since you're finished with it.您需要在登录表单后需要显示的表单上调用
Show
。您可以阅读有关了解表单和表单事件的更多信息You will need call
Show
on the form which needs to be displayed post login form. You can read more about Understanding Forms and form events我的方法是避免尝试将登录表单作为第一个表单打开。
相反,让主窗体位于第一个,并在其加载事件中将登录窗体显示为模式对话框。这可以通过首先在其上进行显示来显示主窗体来完成。基于标准模板“登录对话框”表单的示例,并进行了一些代码更改:
frmMain.frm
frmLogin.frm
My approach is to avoid trying to open a logon Form as the first Form.
Instead let the main Form be first, and in its Load event Show your logon Form as a modal dialog. This can be done revealing the main Form first by doing a Show on it. Example based on the standard template "Log in Dialog" Form with some code changes:
frmMain.frm
frmLogin.frm