我有两个不同的用户控件类。我试图通过另一个用户控件为一个用户控件设置文本框文本。我的财产取得成功,但该集合并没有做任何事情。如何解决这个问题?我已经在下面发布了相关的代码片段。Usercontrol为其他用户控件设置文本框文本
incidentCategorySearchControl.cs
public partial class incidentCategorySearchControl : UserControl
{
private void dataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
incidentCategoryChange incCatChange = new incidentCategoryChange();
//textBox1.Text = incCatChange.TextBoxCategory; // works
incCatChange.TextBoxCategory="test"; // doesn't work
}
}
incidentCategoryChange.cs
public partial class incidentCategoryChange : UserControl
{
public incidentCategoryChange()
{
InitializeComponent();
}
public string TextBoxCategory
{
get { return incidentCategoryTextBox.Text; }
set { incidentCategoryTextBox.Text = value; }
}
}
TextBoxCategory不是文本框,它是一个字符串 – 26071986 2014-10-08 14:18:16
给出错误字符串不包含文本的定义 – Sybren 2014-10-08 14:19:57