In the event handler for CellValueChanged, for a certain condition, I want the focus to stay in the cell and clear its content. What's happening is focus (cursor) is in the next cell when the handler finishes its work. It needs to be in the same cell that caused the event.
MyGrid.CellValueChanged -= new DataGridViewCellEventHandler(CellValueChanged);
if (condition)
{
MyGrid.Rows[e.RowIndex].Cells["ColumnName"].Value = "";
MyGrid.CurrentCell = MyGrid["ColumnName", e.RowIndex];
MyGrid.BeginEdit(true);
return;
}
....