473,495 Members | 2,058 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

"Operation is not valid because it results in a reentrant call to the SetCurrentCellA

1 New Member
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.RemoveAt(index) then exception throws "Operation is not valid because it results in a reentrant call to the SetCurrentCellAddressCore 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.InvalidOperationException: Operation is not valid because it results in a reentrant call to the SetCurrentCellAddressCore function.
at System.Windows.Forms.DataGridView.SetCurrentCellAd dressCore(Int32 columnIndex, Int32 rowIndex, Boolean setAnchorCellAddress, Boolean validateCurrentCell, Boolean throughMouseClick)
at System.Windows.Forms.DataGridView.OnRemovingRow(In t32 rowIndexDeleted, Point& newCurrentCell, Boolean force)
at System.Windows.Forms.DataGridViewRowCollection.Rem oveAtInternal(Int32 index, Boolean force)
at System.Windows.Forms.DataGridViewRowCollection.Rem oveAt(Int32 index)
MY code is simmilar at below:

private void grdListItems_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
if (cellAmt == 0)
{
RemoveZeroDollarEntry(e.RowIndex);
}
}
And
private void RemoveZeroDollarEntry(int rowIndex)
{
do something...
grdListItems.Rows.RemoveAt(rowIndex);
}
Can any one give the correct solution? please. For googling i have went to below location http://social.msdn.microsoft.com/forums/en-US/winformsdatacontrols/thread/f824fbbf-9d08-4191-98d6-14903801acfc/ http://blogs.dotnetnerds.com/steve/archive/2007/05/17/DataGridView-Reentrant-Call-Nightmare.aspx
________________________________________
Dec 2 '11 #1
0 1750

Sign in to post your reply or Sign up for a free account.

Similar topics

0
729
by: Martin B | last post by:
Hallo to everyone! Problem: -------- GridView Exception: reentrant call to the SetCurrentCellAddressCore function System: ------- WinXP Professional, english, .NET Framework 2.0 Beta...
6
11026
by: junky_fellow | last post by:
what are reentrant functions? What are the characteristics of a reentrant code ? what things should be kept in mind while writing a reentrant code ?
28
1995
by: romy | last post by:
What's the easiest way to verify the user had entered a valid date ?
9
8276
by: TheOne | last post by:
Would anyone please point me to a list of reentrant C library functions? I want to know which C library functions are safe to use inside a signal handler across all platforms. Does GNU C library...
13
26572
by: mitchellpal | last post by:
i am really having a hard time trying to differentiate the two..........i mean.....anyone got a better idea how each occurs?
0
6770
by: news.microsoft.com | last post by:
I got this error when i bind dataview to datagridview data.Datasource= dt.DataView Error: Operation is not valid because it results in a reentrant call to the SetCurrentCellAddressCore function...
24
6546
by: John | last post by:
I know this is a very fundamental question. I am still quite confused if the program call stack stack should always grows upwards from the bottom, or the opposite, or doesn't matter?? That means...
8
36061
by: hoofbeats95 | last post by:
I don't think this should be this complicated, but I can't figure it out. I've worked with C# for several years now, but in a web environment, not with windows form. I have a form with a query...
1
2021
by: dearprasan | last post by:
Hi, I am making a call to a asynchronous call to a webservice using callback. Before I make the asynchronous call, I am allowed to make the following cast: IHTMLDocument2 doc = (IHTMLDocument2)...
0
4221
by: ANILMOURYA | last post by:
private void FlexGrdRsltConv_CellEnter(object sender, DataGridViewCellEventArgs e) { if (blnRowenter) { return;} if...
0
7120
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7196
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6878
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5456
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4897
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4583
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1405
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.