属性
来源:互联网 发布:php oa系统原理 编辑:程序博客网 时间:2024/06/10 21:04
public class MyUser
...{
private string name;
private string pwd;
public string Name
...{
get
...{
return this.name;
}
set
...{
this.name = value;
}
}
public string Pwd
...{
get
...{
return this.pwd;
}
set
...{
this.pwd = value;
}
}
public MyUser(string name, string pwd)
...{
this.name = name;
this.pwd = pwd;
}
}
...{
private string name;
private string pwd;
public string Name
...{
get
...{
return this.name;
}
set
...{
this.name = value;
}
}
public string Pwd
...{
get
...{
return this.pwd;
}
set
...{
this.pwd = value;
}
}
public MyUser(string name, string pwd)
...{
this.name = name;
this.pwd = pwd;
}
}
在命名空间里添加一个类
在需要的窗体里再添加
public partial class Form4 : Form
...{
private MyUser user;
public MyUser LoginUser
...{
get
...{
return this.user;
}
set
...{
this.user = value;
if (this.user != null)
...{
this.textBox1.Text = this.user.Name;
this.textBox2.Text = this.user.Pwd;
}
}
}
public Form4()
...{
InitializeComponent();
}
private void Form4_Load(object sender, EventArgs e)
...{
if (this.user != null)
...{
this.textBox1.Text = this.user.Name;
this.textBox2.Text = this.user.Pwd;
}
}
}
...{
private MyUser user;
public MyUser LoginUser
...{
get
...{
return this.user;
}
set
...{
this.user = value;
if (this.user != null)
...{
this.textBox1.Text = this.user.Name;
this.textBox2.Text = this.user.Pwd;
}
}
}
public Form4()
...{
InitializeComponent();
}
private void Form4_Load(object sender, EventArgs e)
...{
if (this.user != null)
...{
this.textBox1.Text = this.user.Name;
this.textBox2.Text = this.user.Pwd;
}
}
}
调用语句:
private void button3_Click(object sender, EventArgs e)
...{
Form4 fm2 = FormCache.GetForm("WinFormTest.Form4") as Form4;
fm2.LoginUser = null;
fm2.Show();
}
private void button4_Click(object sender, EventArgs e)
...{
Form4 fm2 = FormCache.GetForm("WinFormTest.Form4") as Form4;
fm2.LoginUser = new MyUser("这是用户名", "这里是密码");
fm2.Show();
}
...{
Form4 fm2 = FormCache.GetForm("WinFormTest.Form4") as Form4;
fm2.LoginUser = null;
fm2.Show();
}
private void button4_Click(object sender, EventArgs e)
...{
Form4 fm2 = FormCache.GetForm("WinFormTest.Form4") as Form4;
fm2.LoginUser = new MyUser("这是用户名", "这里是密码");
fm2.Show();
}
- 属性
- 属性
- 属性
- 属性
- 属性
- 属性
- 属性
- 属性
- 属性
- 属性
- 属性
- 属性
- 属性
- 属性
- 属性
- 属性
- 属性
- 属性
- 用过滤器限制Web服务的访问权限
- CSS filter过滤器支持表
- 学习C#2.0新特性:泛型!
- D-Day +1 of .NET >确实是好书...还是边学边实践比较好
- 随笔-装宽带
- 属性
- 基于IP多播的组讨论会实例分析一
- 用css制作表单并体验亲和力
- 在.NET环境下发送邮件
- 重用VB6
- ListItem[] 类型如何在 VB.net中表示
- 发送邮件程序(Csharp2005)
- 《给初学者的Windows Vista的补遗手册》之016
- 95%的中国网站需要重写CSS-写在px和em的区别下