I'm using the following code to update a DataGridView's cell value. This is called inside the 'CellDoubleClick' event handler for the DataGridView.
The problem is the cell only updates after I click onto another cell. Is there a better way of doing this?
string value = "";
if (_dataGrid1.CurrentRow.Cells[e.ColumnIndex].Value != null)
value = _dataGrid1.CurrentRow.Cells[e.ColumnIndex].Value.ToString();
FormEdit form = new FormEdit(value); // takes a string value
if (form.ShowDialog() == DialogResult.OK)
{
_dataGrid1.CurrentRow.Cells[e.ColumnIndex].Value = form.SourceText;
_dataGrid1.UpdateCellValue(e.ColumnIndex, e.RowIndex);
}
Some variable names were changed to protect their identity