PC Review


Reply
Thread Tools Rate Thread

DataGridView: InvalidOperationException was unhandled

 
 
nvx
Guest
Posts: n/a
 
      3rd Sep 2007
Hello,
I get the InvalidOperationException: "Operation did not succeed
because the program cannot commit or quit a cell value change." in
case I set value of a field in a data-bound DataGridView. Needless to
say this DataGridView is on a TabControl's TabPage which has not yet
been selected from the moment application has been run.

An example:
1. Let's run the application. Upon startup, we see the first TabPage
of the TabControl (say tabPage1). Our DataGridView is on another
TabPage, say tabPage2, so we do not see it now. We do not select
tabPage2 yet, thus preventing the DataGridView to be painted.
2. A certain method is run upon clicking a button in the toolbar. This
method changes value of a cell in our DataGridView, that is still
hidden.
3. Now, if we select tabPage2, InvalidOperationException: "Operation
did not succeed because the program cannot commit or quit a cell value
change." occurs.

In case user has already selected the TabPage containing the
DataGridView (even for an instant) before clicking the toolbar button
(and changing the cell's value), no exception occurs.

I believe something happens when the data-bound DataGridView is viewed
for the first time, but I do not know what it is. Any ideas what
should I do in tabControl_Selecting(...) or somewhere else to commit
the change to the cell and prevent this exception from occuring? I
know it would not occur if I used dataGridView.CancelEdit();, but this
resets the value of the changed cell to its previous value and I loose
the change I made...

Thanks a lot for any help...


Best regards
nvx

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
an unhandled win32 exception was unhandled occurred in inetinfo.exe Warren Tang Microsoft ASP .NET 1 23rd Sep 2008 04:01 PM
System.InvalidOperationException will be thrown if I call the method DataGridView.Rows.Add, How to resolve? Ryan Microsoft C# .NET 2 16th Oct 2006 05:41 PM
InvalidOperationException with DataGridView bound to object data source bort Microsoft Dot NET Framework 0 15th Mar 2006 06:09 PM
Clearing selection in DataGridView when user clicks outside the DataGridView control djyakov@gmail.com Microsoft Dot NET Framework Forms 0 16th Feb 2006 06:38 PM
Started getting "InvalidOperationException was unhandled" since upgrading to .Net 2.0 Ben Fidge Microsoft ADO .NET 3 14th Feb 2006 11:22 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:47 AM.