Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
I have a VB windows form app with a datagridview. I changed one of the column types to a combobox, which works ok. However, when I close out of the form I get multiple 'datagridview default error dialogue' complaining about system.index out of range, one error for each row by the look of it.

No cell data was added or changed.

Any suggestions as to what might be going on?

What I have tried:

So, I found that the DataSet for the combo box, which is a "Lookup" that contains two fields, CustomerID and LastName has a parameter to toggle "Enforce Constraints". By setting to false, the error goes away. CustomerID is a key field.
Posted
Updated 1-Apr-24 6:49am
v4
Comments
Member 15627495 1-Mar-24 3:13am    
without your code, we really can't fix your bug.
guessing is not possible... Vb code could be hundreds of methods/event/writing

please, show us the living code, target the lines about the bug.
Richard Deeming 1-Mar-24 4:01am    
Agreed - no code, and only a vague hand-waving summary of the error rather than the actual exception details, means there is no way for anyone to help.
Graeme_Grant 1-Mar-24 5:56am    
It sounds like you have hooked the form closing event and trying to process the DataGridView cells. you need to set a breakpoint in that code or break on all errors.
Graeme_Grant 1-Mar-24 5:56am    
It sounds like you have hooked the form closing event and trying to process the DataGridView cells. you need to set a breakpoint in that code or break on all errors.
Member 15485980 31-Mar-24 22:59pm    
I set various breakpoints around the form closing event with nothing that made any sense.

1 solution

We can't tell - we have no access to your code, especially not while it is running.
So, it's going to be up to you.

Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. If you don't know how to use it then a quick Google for "Visual Studio debugger" should give you the info you need.

Use the debugger to identify where in your code the event is thrown, and from that find the event handler that is responsible. Put a breakpoint on the first line in the method, and run your code again through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.

Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900