【发布时间】:2018-09-13 23:27:20
【问题描述】:
在我的 datagridview 中,我在 winforms 中有一个 textboxcolumn 和一个可编辑的组合框列。但是在组合框文本中键入新值并按 Enter 键时,我没有将键入的值作为相应的单元格值。有人可以请帮助解决这个问题。
private void dgv_customAttributes_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
DataGridViewRow row = dgv_customAttributes.CurrentRow;
if (row.Cells[1].Value.ToString() != null)
{
//Here the selectedVal is giving the old value instead of the new typed text
string SelectedVal = row.Cells[1].Value.ToString();
foreach (CustomAttribute attribute in customAttributes)
{
if (row.Cells[0].Value.ToString() == attribute.AttributeName)
{
attribute.AttributeValue = SelectedVal;
break;
}
}
}
}
【问题讨论】:
-
我不能说我确切地知道你正在做的事情会发生什么,但我知道绑定的组合框列的每一行必须具有相同的数据源。我不认为这对你有用。你可能会使用不同的机制,比如弹出一个模态选择列表。
标签: c#