0

My question is similar to below, except that i dont know whats the alternative.

Why is my bound DataGridView throwing an "Operation not valid because it results in a reentrant call to the SetCurrentCellAddressCore function" error?

When user finishes editing, the datagridview should refresh and display only those records which satisfy the gird's dataview criteria. so at the end of EndEdit i call doubleClick event of a control which populates the grid again according to the criteria. this approach works fine as long as the edit is complete. but if the user is still in edit mode & any other cell of the same datagridview is clicked i get this exception.

Operation is not valid because it results in a reentrant call to the SetCurrentCellAddressCore function.

every other control is good because grid is out of edit mode. I have tried:

datagridview.CancelEdit();

before assigning the datasource to the grid again, but it gives the same exception.

Community
  • 1
  • 1
PUG
  • 4,301
  • 13
  • 73
  • 115
  • 1
    Found the answer folks: > http://stackoverflow.com/questions/893752/invalidoperationexception-when-ending-editing-a-cell-moving-to-another-cell – PUG Nov 01 '11 at 19:15

1 Answers1

2

If you refresh the grid a-sync using

this.BeginInvoke(new MethodInvoker(Refresh_dataGridView1));

that should solve the problem. More details here

Community
  • 1
  • 1
PUG
  • 4,301
  • 13
  • 73
  • 115