【发布时间】:2014-02-09 05:42:10
【问题描述】:
我有一个包含两种形式的项目。我必须将form2 中的textbox1 数据传递给form1 中定义的变量字符串m。我的代码写在下面,但变量字符串m 是常量。
表格2:
public partial class Form2 : Form
{
Form1 frm1;
public Form2()
{
InitializeComponent();
frm1 = new Form1();
}
private void button1_Click(object sender, EventArgs e)
{
frm1.ModifyTextBoxValue = textBox1.Text;
this.Close();
}
表格一:
public partial class Form1 : Form
{
string m = "12";
public Form1()
{
InitializeComponent();
}
public string ModifyTextBoxValue
{
get { return textBox1.Text; }
set { m = value; }
}
}
【问题讨论】:
-
那么问题出在哪里?