Windows应用程序的登录表单 [英] Login Form for Windows Application

查看:100
本文介绍了Windows应用程序的登录表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我想为我的Windows应用程序创建一个简单的登录表单.我尝试了一些方法并在网络上找到了一些示例,但是它们并不完全适合Winform应用程序.因此,能否请您为包含用户名和密码字段的登录表单(或用户控件)显示一些示例,并检查用户名和密码是否有效,请检查databese.然后,如果有效,则关闭或处理自身并打开Main表单.提前谢谢...
BR.

Hi all,
I want to create a simple Login form for my Windows Application. I have tried some methods and found some examples on the web, but they are not completely suitable for Winform application. So, could you please show some examples for a login form (or user control) which contains username and password field and check databese if the user id and password is valid. Then, if valid close or dispose itself and open Main form. Thanks in advance...
BR.

推荐答案

对于winforms登录:

WinForm应用程序的用户登录 [ C#Apps中的多个后续主"表单 [ ^ ]
For winforms login:

User Login For WinForm Applications[^]

For Opening another form after logging in:

Multiple Subsequent "Main" Forms in C# Apps[^]


您可能不会找到一个简单的示例,它完全符合您的要求.我认为您最好的选择是开始制作自己的示例,遇到麻烦时再提出一些具体问题.

本文 [这是一个提示/技巧 [
You''re probably not going to find one one simple example that has exactly what you are looking for. I think your best option is to just start making your own example and come back with specific questions when you run into trouble.

This article[^] looks like a good overview about storing passwords. I thought it might help get you started.

Here is a tip/trick[^] that might help, too.


这就是我要做的...

登录表格:

创建一个表单"frmLogIn",并给以IsAuthorized的公共属性(布尔).
将两个文本框添加到窗体,使其中一个成为密码框(使用掩码字符).
添加一个取消按钮(使其成为对话框的取消)和一个确定按钮(使其成为对话框的确定​​).
在取消"上,将IsAuthorized设置为false并关闭表单(将控件返回到main()).
单击确定,然后进行数据库验证并适当地设置IsAuthorized(取决于db验证).

主要:

程序启动时,启动登录表单,最初检查DialogResult == OK.

如果可以,请启动您的主应用程序窗体...否则,让它通过main()退出并退出.

如果您对这些基本项目有任何具体问题,可以提出这些建议,并按照kschuler的建议查看可以得到的提示.

祝你好运!
Here''s what I would do...

Login Form:

Create a form "frmLogIn", and give is a public property (bool) of IsAuthorized.
Add two text boxes to the form, make one of them a password box (using masking characters).
Add a cancel button (make it the cancel for the dialog), and an OK button (make it the OK for the dialog).
On Cancel, set IsAuthorized to false and close the form (returning control to main()).
On OK, do database verification and set IsAuthorized appropriately (depending on db verification).

Main:

When the program starts, launch the login form initially checking for DialogResult == OK.

If OK, launch your main application form... else just let it drop through main() and exit.

If you have any specific questions on those basic items you can pose those and see what kind of tips you can get as kschuler suggested.

Good luck!


这篇关于Windows应用程序的登录表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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