从一种形式重定向到另一种Windows形式 [英] redirecting from one form to another windows form

查看:75
本文介绍了从一种形式重定向到另一种Windows形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想在成功登录后关闭登录表单,并将其重定向到另一个表单.
所以我用this.hide();
隐藏方法还有其他选择吗? ??????
这指向当前形式对吗? ????
和"this.Hide()"应该仅在调用新表单的代码之后编写
na ? ???

Hi
I wanna to close the login form after it''s successfully logged in and redirect it to another form.
so I used this.hide();
Is there any other alternative to hide method ???????
and this points to current form right ?????
and "this.Hide()" should be written only after the code for invoking a new form
na ????

推荐答案

基于公认的设计,在Winforms中解决此类问题的步骤:
1.具有主要形式-形式A.始终保持活动状态.
2.由于您需要登录,因此创建一个子窗体-窗体B.在窗体A上方显示它.
3.如果用户提供正确的凭据,请根据需要隐藏/关闭表单B并使用UI显示表单A
4.如果用户提供了错误的凭据,请显示错误

这样,您就不会出现登录表单的打开/关闭问题.此外,您必须在Winforms中知道,不能关闭父窗口并保持子窗口处于打开状态-因此上述设计将检查所有内容而不会出现问题.
Steps for such scenarios in Winforms, based on good accepted design:
1. Have a main form - form A. Always keep it active.
2. Since you need login, create a child form - form B. Show it above form A.
3. If user provides correct credentials, hide/close form B and show form A with UI as per need
4. If user provides wrong credentials, show error

This way, you don''t have issue with opening/closing issue with login form. Further, as you must be knowing in Winforms, parent window cannot be closed keeping child window open - thus the above said design would keep everything in check without issues.


这篇关于从一种形式重定向到另一种Windows形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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