Hi, I have a datagrid of one column and many rows. Cell become editable when i click on the cell. i have a stutation in which if i edit the cell value to zero and click on the next cell then leaving cell (0.00) should be remove at that location. But movement i click on next cell cellEditEnd methos gets called and in this method i have written the code to remove the cell. But when it try to remove the cell but code datagrid.rows.R emoveAt(index) then exception throws "Operation is not valid because it results in a reentrant call to the SetCurrentCellA ddressCore function".While googling i found many workaround for this case e.g Using beginivoke method with deegate or set focus some aother controls or Disbale the grid before the remove cell. But i didn't got the solution. Exception throws when removing the rows from the grid. Below is stack trace:
---> System.InvalidO perationExcepti on: Operation is not valid because it results in a reentrant call to the SetCurrentCellA ddressCore function.
at System.Windows. Forms.DataGridV iew.SetCurrentC ellAddressCore( Int32 columnIndex, Int32 rowIndex, Boolean setAnchorCellAd dress, Boolean validateCurrent Cell, Boolean throughMouseCli ck)
at System.Windows. Forms.DataGridV iew.OnRemovingR ow(Int32 rowIndexDeleted , Point& newCurrentCell, Boolean force)
at System.Windows. Forms.DataGridV iewRowCollectio n.RemoveAtInter nal(Int32 index, Boolean force)
at System.Windows. Forms.DataGridV iewRowCollectio n.RemoveAt(Int3 2 index)
MY code is simmilar at below:
private void grdListItems_Ce llEndEdit(objec t sender, DataGridViewCel lEventArgs e)
{
if (cellAmt == 0)
{
RemoveZeroDolla rEntry(e.RowInd ex);
}
}
And
private void RemoveZeroDolla rEntry(int rowIndex)
{
do something...
grdListItems.Ro ws.RemoveAt(row Index);
}
Can any one give the correct solution? please. For googling i have went to below location http://social.msdn.mic rosoft.com/forums/en-US/winformsdatacon trols/thread/f824fbbf-9d08-4191-98d6-14903801acfc/ http://blogs.dotnetner ds.com/steve/archive/2007/05/17/DataGridView-Reentrant-Call-Nightmare.aspx
_______________ _______________ __________
---> System.InvalidO perationExcepti on: Operation is not valid because it results in a reentrant call to the SetCurrentCellA ddressCore function.
at System.Windows. Forms.DataGridV iew.SetCurrentC ellAddressCore( Int32 columnIndex, Int32 rowIndex, Boolean setAnchorCellAd dress, Boolean validateCurrent Cell, Boolean throughMouseCli ck)
at System.Windows. Forms.DataGridV iew.OnRemovingR ow(Int32 rowIndexDeleted , Point& newCurrentCell, Boolean force)
at System.Windows. Forms.DataGridV iewRowCollectio n.RemoveAtInter nal(Int32 index, Boolean force)
at System.Windows. Forms.DataGridV iewRowCollectio n.RemoveAt(Int3 2 index)
MY code is simmilar at below:
private void grdListItems_Ce llEndEdit(objec t sender, DataGridViewCel lEventArgs e)
{
if (cellAmt == 0)
{
RemoveZeroDolla rEntry(e.RowInd ex);
}
}
And
private void RemoveZeroDolla rEntry(int rowIndex)
{
do something...
grdListItems.Ro ws.RemoveAt(row Index);
}
Can any one give the correct solution? please. For googling i have went to below location http://social.msdn.mic rosoft.com/forums/en-US/winformsdatacon trols/thread/f824fbbf-9d08-4191-98d6-14903801acfc/ http://blogs.dotnetner ds.com/steve/archive/2007/05/17/DataGridView-Reentrant-Call-Nightmare.aspx
_______________ _______________ __________