还记得VB.NET(VS 2008)中的我复选框吗? [英] Remember Me Check Box in VB.NET (VS 2008) ?

查看:92
本文介绍了还记得VB.NET(VS 2008)中的我复选框吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,这又是我.. VB.NET的新手...

Dear All, this is me again.. a newbie to VB.NET...

 

我需要帮助...

 

如何使用VB.NET在桌面应用程序中创建记住我" Chechkbox.

how to create Remember me Chechkbox in Desktop application with VB.NET.

 

情况是这样,我有一个登录表单,我的客户说她将把该应用程序出售给不足够记住用户名和密码的人,因此她要求我在登录表单中添加记住我的功能". ..

so the case is, i have a login form, and my customer said that she will sell the application to people who doesnt good enough to memorize username and password, so she ask me to put remember me function to the login form...

 

请帮我...给我看看一些例子

please help me... show me some example

 

谢谢

 

致谢

 

 

推荐答案

您可以使用应用程序设置.

You could use Application Settings.

在解决方案资源管理器中双击我的项目".单击左窗格中的设置.现在,您需要创建至少2个设置,并根据需要创建更多设置.

Double Click on My Project in Solution Explorer. Click Settings in left pane. Now you need to create atleast 2 settings, and more depending on your requirements.

将第一个设置命名为SessionAlive |类型:布尔|范围:用户|值:错误

Name the first setting as SessionAlive | Type:Boolean | Scope :User | Value : False

将第二个设置命名为Username |.类型:字符串|范围:用户|值:保持空白

Name the second setting as Username | Type:String | Scope :User | Value : keep empty

现在,在登录框中,单击登录按钮,成功登录后,如果选中了复选框,则应保存登录信息.它将是:

Now, in Login box, in log-in button click, after a successful login, you should save the login information if checkbox is checked. So it will be :

private sub login_button_click(以发件人为对象,以eEventArgs为对象)处理login_button.Click

  if(RememberMeCheckBox.Checked)然后

 if(RememberMeCheckBox.Checked) Then

  My.Settings.SessionAlive = True
  My.Settings.Username ="CurrentUser的用户名"

  My.Settings.SessionAlive = True
  My.Settings.Username = "CurrentUser's Username"

 如果
则结束

 End if

结束子

 

在保存会话时,还应在表单加载期间检查当前会话.

As you are saving the sessions, you should also check for current session during form load.

所以代码将类似于

private sub form_load()....

if(My.Settings.SessionAlive)然后

  登录已保存,请在此处获取用户名并处理下一张表单

  "My.Settings.Username"将返回保存的用户名.

结束子

 

此外,如果需要,还应允许用户清理会话.那是注销方法中的某个地方,您应该设置

Also, you should allow the user to clean up the session if required. That is somewhere in Logout method, you should set

My.Settings.SessionAlive = False

My.Settings.SessionAlive = False

My.Settings.Username = String.Empty.

My.Settings.Username = String.Empty.

 

对于那些可能忘记用户名和密码的人来说,这不是一个真正的解决方案.您应该通过询问安全问题或类似机制来提供一种恢复其密码的方法.

This is not a real solution for people who may forget their username and passwords. You should provide a way to recover their passwords by asking a security question or similar mechanism.

在关键应用程序中保存会话也很危险.您应该通过在复选框旁边放置一个标签来使用户知道保存会话"是什么,如果应用程序位于共享计算机上,告诉他们避免保存会话.

It is also dangerous to save sessions in critical applications. You should make user aware of what Saving Session is by putting a label next to Checkbox, telling them to avoid saving sessions if application is on shared computer.

 


这篇关于还记得VB.NET(VS 2008)中的我复选框吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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