在我的DataGridView中,我有一个文本框列和一个可编辑的组合框列在Winforms中。但是,当我在组合框文本框中输入新值并按下回车键时,我没有得到所键入的值作为相应单元格的值。请问有谁能帮忙解决这个问题?
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;
}
}
}
}