This error is caused by
Any operation that changes the active cell when the DataGridView is still using it
Like the accepted answer in this post .
Bugfix (I checked): use BeginInvoke to call moveRowTo .
private void dataGridView2_CellEndEdit(object sender, DataGridViewCellEventArgs e) { this.BeginInvoke(new MethodInvoker(() => { moveRowTo(dataGridView2, 0, 1); })); }
BeginInvoke is an asynchronous call, so dataGridView2_CellEndEdit returns immediately, and then dataGridView2 is moveRowTo , then dataGridView2 no longer uses the current active cell.
source share