简体   繁体   English

text_changed事件不起作用

[英]text_changed event not working

private void txtName_TextChanged(object sender, EventArgs e)
{
    if (dataGridView1.SelectedRows.Count == 1)
    {
        dataGridView1.SelectedRows[0].Cells["someValue"].Value = txtName.Text;
    }
}

When the text is changed in the text box it should be displayed in the datagrid view,if i select cell already having data then it works fine but if i select a new row(empty row) the text does not appear in the datagridview allow user to add row is set to true for the datagrid view. 当文本在文本框中更改时,应在datagrid视图中显示,如果我选择已经有数据的单元格,则可以正常工作,但是如果我选择新行(空行),则该文本不会出现在datagridview允许用户中对于datagrid视图,将添加行设置为true。

确保您的文本框AutopostBack属性设置为“ true”。否则,不会触发textchanged事件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM