Click here to Skip to main content
15,913,941 members
Home / Discussions / C#
   

C#

 
GeneralRe: Show a hidden console again? Pin
Don Rolando16-Sep-11 0:23
Don Rolando16-Sep-11 0:23 
GeneralRe: Show a hidden console again? Pin
V.16-Sep-11 0:36
professionalV.16-Sep-11 0:36 
GeneralRe: Show a hidden console again? Pin
Don Rolando16-Sep-11 0:47
Don Rolando16-Sep-11 0:47 
AnswerRe: Show a hidden console again? Pin
Alan N16-Sep-11 3:04
Alan N16-Sep-11 3:04 
GeneralRe: Show a hidden console again? Pin
Don Rolando16-Sep-11 3:19
Don Rolando16-Sep-11 3:19 
AnswerRe: Show a hidden console again? Pin
PIEBALDconsult16-Sep-11 3:19
mvePIEBALDconsult16-Sep-11 3:19 
GeneralRe: Show a hidden console again? Pin
Don Rolando16-Sep-11 3:22
Don Rolando16-Sep-11 3:22 
QuestionDataGridView throws Data Pin
beauroak15-Sep-11 15:15
beauroak15-Sep-11 15:15 
C#
I have been looking all over for an answer to this question and can't find something that fits exactly what I am trying to do.

I have a DataGridView that is bound to a DataTable, which is part of a strongly typed DataSet from a SQL Server DB.  I can manually update the DataGridView fine.  However, my program has multiple threads, one of which adds and removes rows of the underlying data in the DataTable to which the DataGridView is bound.  This itself works ok sometimes, but at other times I receive the following exception: 

Exception in DataGridView: System.IndexOutOfRangeException: Index 9 does not have a value at System.Windows.Forms.CurrencyManager.get_Item(Int32 index) at System.Windows.Forms.DataGridView.DataGridViewDataConnection.GetError(Int32 boundColumnIndex, Int32 columnIndex, Int32 rowIndex)
To replaces this default dialog please handle the DataError event.

I have written test code and have confirmed that the problem seems to arise because the DataTable is being changed on a different thread.  When I add/remove rows on the GUI thread, all is fine.  But when I add/remove rows from a different thread, I get the Exception.

I have tried to use the Delete method rather than the Remove method in the DataTable class, but that does not seem to make a difference.  And for purposes of my program, it is highly undesirable to change the structure of the program so that the GUI thread makes the changes to the DataTable.  I suppose an option might be to catch the DataError exception and do nothing with it, but that is really a last resort. Please help here!  

AnswerRe: DataGridView throws Data Pin
Luc Pattyn15-Sep-11 15:29
sitebuilderLuc Pattyn15-Sep-11 15:29 
Questionretrive gridview cell value Pin
jashimu15-Sep-11 9:55
jashimu15-Sep-11 9:55 
AnswerRe: retrive gridview cell value Pin
walterhevedeich15-Sep-11 15:56
professionalwalterhevedeich15-Sep-11 15:56 
Questionhow to write regular expression for this code? Pin
SRKSHOME15-Sep-11 6:48
SRKSHOME15-Sep-11 6:48 
AnswerRe: how to write regular expression for this code? Pin
BillWoodruff15-Sep-11 7:33
professionalBillWoodruff15-Sep-11 7:33 
GeneralRe: how to write regular expression for this code? Pin
SRKSHOME15-Sep-11 19:43
SRKSHOME15-Sep-11 19:43 
AnswerRe: how to write regular expression for this code? Pin
OriginalGriff15-Sep-11 8:26
mveOriginalGriff15-Sep-11 8:26 
GeneralRe: how to write regular expression for this code? Pin
PIEBALDconsult15-Sep-11 9:10
mvePIEBALDconsult15-Sep-11 9:10 
GeneralRe: how to write regular expression for this code? Pin
OriginalGriff15-Sep-11 9:15
mveOriginalGriff15-Sep-11 9:15 
GeneralRe: how to write regular expression for this code? Pin
BillWoodruff15-Sep-11 21:42
professionalBillWoodruff15-Sep-11 21:42 
GeneralRe: how to write regular expression for this code? Pin
BillWoodruff15-Sep-11 21:43
professionalBillWoodruff15-Sep-11 21:43 
GeneralRe: how to write regular expression for this code? Pin
SRKSHOME15-Sep-11 20:21
SRKSHOME15-Sep-11 20:21 
GeneralRe: how to write regular expression for this code? Pin
Pete O'Hanlon15-Sep-11 20:32
mvePete O'Hanlon15-Sep-11 20:32 
GeneralRe: how to write regular expression for this code? Pin
SRKSHOME15-Sep-11 21:03
SRKSHOME15-Sep-11 21:03 
AnswerRe: how to write regular expression for this code? Pin
Luc Pattyn15-Sep-11 10:41
sitebuilderLuc Pattyn15-Sep-11 10:41 
GeneralRe: how to write regular expression for this code? Pin
PIEBALDconsult15-Sep-11 14:44
mvePIEBALDconsult15-Sep-11 14:44 
AnswerRe: how to write regular expression for this code? Pin
Luc Pattyn15-Sep-11 14:47
sitebuilderLuc Pattyn15-Sep-11 14:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.