原文如下:
第1步:在解决方案上添加一个窗体Form2;并添加textBox1、textBox2、Button1,将Button1的标题设为“确定”,DialogResult属性设为“OK”;
第2步:在窗体Form2的类代码中添加两个私有字段: _username、_password,并添加两个public属性:UserName、Password;代码如下:




























第3步:窗体间相互传值演示
在Form1添加一个的Botton1、一个comboBox1,在Botton1_Click函数中如下代码:












要充分演示上述功能,还需要对Form2的代码作如下完善:
第1,在Form2_Load中添加如下代码:





第2,在textBox1、textBox2的textChanged事件中添加如下代码:







