C#将值赋给另一窗口的TextBox
有form1和form2两个窗口,form1有一个按钮,里面有一个string str="V1001",点击一下按钮,在form2的TextBox中显示出str的值。public partial class Form1 : Form
{
public str;
publicForm1()
{
InitializeComponent();
}
privatevoid button1_Click(objectsender, EventArgs e)
{
Form2 form2=new Form2();
str="V1001";
form2.Show();
}
}
public partial class Form2 : Form
{
form1 fm=new form1();
publicForm2()
{
InitializeComponent();
}
privatevoid Form2_Load(objectsender, EventArgs e)
{
this.TextBox1.Text=fm.str;
}
}