Winform实现登录窗体记住密码的功能
2011-10-27 10:26
666 查看
Winform实现登录窗体记住密码的功能,如图:
代码如下:
1、窗体Form1加载:
List<UserInfo> item=new List<UserInfo>();
UserInfo userInfo = new UserInfo();
BUserInfo bUserInfo = new BUserInfo();
Dictionary<string, UserInfo> users = new Dictionary<string, UserInfo>();
private void Form1_Load(object sender, EventArgs e)
{
FileStream fs = new FileStream("data.bin", FileMode.OpenOrCreate);
if (fs.Length > 0)
{
BinaryFormatter bf = new BinaryFormatter();
users = bf.Deserialize(fs) as Dictionary<string, UserInfo>;
foreach (UserInfo user in users.Values)
{
comboBox1.Items.Add(user.UserName);
}
for (int i = 0; i < users.Count; i++)
{
if (comboBox1.Text != "")
{
if (users.ContainsKey(comboBox1.Text))
{
textBox2.Text = users[comboBox1.Text].UserPwd;
checkBox1.Checked = true;
}
}
}
}
fs.Close();
item = (List<UserInfo>)bUserInfo.GetAll();
comboBox1.DataSource = item;
comboBox1.DisplayMember = "UserName";
}
2、选择用户名:
private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
{
FileStream fs = new FileStream("data.bin", FileMode.OpenOrCreate);
if (fs.Length > 0)
{
BinaryFormatter bf = new BinaryFormatter();
users = bf.Deserialize(fs) as Dictionary<string, UserInfo>;
for (int i = 0; i < users.Count; i++)
{
if (comboBox1.Text != "")
{
if (users.ContainsKey(comboBox1.Text) && users[comboBox1.Text].UserPwd != "")
{
textBox2.Text = users[comboBox1.Text].UserPwd;
checkBox1.Checked = true;
}
else
{
textBox2.Text = "";
checkBox1.Checked = false;
}
}
}
}
fs.Close();
}
代码如下:
1、窗体Form1加载:
List<UserInfo> item=new List<UserInfo>();
UserInfo userInfo = new UserInfo();
BUserInfo bUserInfo = new BUserInfo();
Dictionary<string, UserInfo> users = new Dictionary<string, UserInfo>();
private void Form1_Load(object sender, EventArgs e)
{
FileStream fs = new FileStream("data.bin", FileMode.OpenOrCreate);
if (fs.Length > 0)
{
BinaryFormatter bf = new BinaryFormatter();
users = bf.Deserialize(fs) as Dictionary<string, UserInfo>;
foreach (UserInfo user in users.Values)
{
comboBox1.Items.Add(user.UserName);
}
for (int i = 0; i < users.Count; i++)
{
if (comboBox1.Text != "")
{
if (users.ContainsKey(comboBox1.Text))
{
textBox2.Text = users[comboBox1.Text].UserPwd;
checkBox1.Checked = true;
}
}
}
}
fs.Close();
item = (List<UserInfo>)bUserInfo.GetAll();
comboBox1.DataSource = item;
comboBox1.DisplayMember = "UserName";
}
2、选择用户名:
private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
{
FileStream fs = new FileStream("data.bin", FileMode.OpenOrCreate);
if (fs.Length > 0)
{
BinaryFormatter bf = new BinaryFormatter();
users = bf.Deserialize(fs) as Dictionary<string, UserInfo>;
for (int i = 0; i < users.Count; i++)
{
if (comboBox1.Text != "")
{
if (users.ContainsKey(comboBox1.Text) && users[comboBox1.Text].UserPwd != "")
{
textBox2.Text = users[comboBox1.Text].UserPwd;
checkBox1.Checked = true;
}
else
{
textBox2.Text = "";
checkBox1.Checked = false;
}
}
}
}
fs.Close();
}
相关文章推荐
- winform登录窗体实现记住密码功能
- C#-WinForm登录窗体实现记住密码的功能(仿QQ实现)
- C#-WinForm登录窗体实现记住密码的功能(仿QQ实现)
- C# winform 登录窗体 记住密码的实现 --来源http://www.cnblogs.com/ou444/archive/2011/09/13/2174911.html
- Jquery 实现 “下次自动登录” 记住用户名密码功能
- C# winform 登录窗体 记住密码的实现
- Android登录界面用SharedPreferences实现记住密码功能
- (转)业务系统实现记住密码和自动登录功能
- C#序列化实现用户登录记住账号密码功能
- Flex中如何实现类似像QQ登录框中那种“记住密码”、“自动登录”功能,还有如何实现文本框中记录最后一次输入的值?
- 通过jquery.cookie.js实现记住用户名、密码登录功能
- Android登录界面用SharedPreferences实现记住密码功能
- Android登录界面用SharedPreferences实现记住密码功能
- 利用h5的本地存储实现登录页面里的记住账号和密码功能
- 登录时,记住密码功能实现
- 在登录页面如何实现记住用户名和密码这个功能
- Android探索之路:实现登录界面的记住密码功能
- 自动登录,记住密码功能实现
- 登录时简单的记住密码和自动登录功能实现
- 通过jquery.cookie.js实现记住用户名、密码登录功能