我无法编辑文本框中的文字。我需要文本框在开始时显示文本然后可以编辑。 imageName显示在文本框中,但我无法将其编辑为其他内容。
private void image_NameTextBox_TextChanged(object sender, EventArgs e)
{
string imageName = (dictionaryDataSet1.Tables[0].Rows[selectedIndex]["Image Name"].ToString());
image_NameTextBox.Text = imageName;
}
答案 0 :(得分:0)
看起来您已经为TextBox定义了TextChanged-Event。每次编辑文本时,您都在调用处理程序:
private void image_NameTextBox_TextChanged(object sender, EventArgs e)
{
string imageName = (dictionaryDataSet1.Tables[0].Rows[selectedIndex]["Image Name"].ToString());
image_NameTextBox.Text = imageName;
}
结果是:您正在将文本设置回旧值。
从TextBox中删除事件,并用不同的方法填充文本。
答案 1 :(得分:0)
您在TextChanged
事件中拥有代码,这意味着每次您尝试编辑文本时,它都会将其设置为同样的事情。将您的代码移到TextChanged
事件之外(它仍在运行的某个地方),然后尝试编辑您的文本。