一般是用事件,比较安全
登陆窗口中
在button的点击事件中
if(textBox1.Text == "XXX")
{
Form2 form2 = new Form2();
//给主窗口的getvalue赋值
form2.GetValue += () => { return this.textbox.text; };
for m2.Show();
}
主窗口
//申明一个事件
public event Func<string> GetValue;
//给lable赋值
lbl.text = GetValue();