我有两种形式,分别是form1和form2:
form1由label和组成button。
form2由a textBox和a组成button
当我单击form1按钮时,将显示form2。按下中的按钮textBox后,任何输入都应写回。 我有下面的代码,但它不起作用。form1.labelform2
// Code from Form 1
public partial class Form1 : Form
{
public void PassValue(string strValue)
{
label1.Text = strValue;
}
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 objForm2 = new Form2();
objForm2.Show();
}
}
// Code From Form 2
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form1 objForm1 = new Form1();
objForm1.PassValue(textBox1.Text);
this.Close();
}
}
和截图:
应用截图
我怎么能知道呢?