HighTechTalks DotNet Forums  

DataGridView: InvalidOperationException was unhandled

Dotnet Framework (ADO.net) microsoft.public.dotnet.framework.adonet


Discuss DataGridView: InvalidOperationException was unhandled in the Dotnet Framework (ADO.net) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
nvx
 
Posts: n/a

Default DataGridView: InvalidOperationException was unhandled - 09-03-2007 , 02:09 PM






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 Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.