Click to See Complete Forum and Search --> : DataGridView ignore index out of bounds


PeejAvery
September 2nd, 2009, 09:22 AM
Is there a way to force my application to ignore the index out of bounds error from the DataGridView? I have gone through from top to bottom and there is no reason why I should be receiving this error. No operations, rows, nor columns are affected by just continuing past the error.

HanneSThEGreaT
September 3rd, 2009, 12:50 AM
The following is actually bad advice.

You could add a Try and catch block, and provide nothing in the catch section, as in :
Try
' Your Code Here
Catch ex As IndexOutOfBoundsException
'Do Nothing Here, Leave Empty!
End Try

Now, whenever you get this exception, it gets "skipped", because we said nothing should happen when it occurs.

The whole reason why I said it is bad advice actually, is because, this type of exception may influence other parts of your code / program.

You said :
and there is no reason why I should be receiving this error

This is where the Good advice comes in :)

There is always a reason for an error, sometimes it may just not be very obvious, I'd actually recommend having a closer look at all the particular code, propertis set etc.

I hope my comments wre useful... And Good luck! :thumb:

PeejAvery
September 3rd, 2009, 08:15 AM
Here's my exact predicament...it makes no sense to me.


I have a CSV file which loads to a DataGridView perfectly fine. No error whatsoever.
If I click a column so that it sorts, I receive the error.
However, if I click another column so that the sort order (asc, desc) is the same, but the column is different, I don't see the error again.
But, it seems that the moment asc or desc is changed, that's when I receive the error.

HanneSThEGreaT
September 3rd, 2009, 08:25 AM
What code do you use for Sorting, did you write your own custom code ¿

PeejAvery
September 3rd, 2009, 08:25 AM
No custom code whatsoever. I just let the DataGridView handle it, itself.

HanneSThEGreaT
September 3rd, 2009, 08:27 AM
Interesting ... :confused:

Is it possible to add your CSV file and form with the DGV on it here, your project / smaller representation of it ¿

PeejAvery
September 3rd, 2009, 08:32 AM
Unfortunately, I cannot. It is a sensitive document. The whole things is based upon login information and accounts. I would pretty much have to create a fake one to do so.

Here's the format: firstname, lastname, username, password, email, address, phone, datecreated, dateexpires

PeejAvery
September 3rd, 2009, 08:34 AM
I have an idea...I'm going to remove the last line return of the document. Since I am temporarily adding to each line as it is read into the DataGridView, I bet this is creating a problem.

I'll post back as soon as I try it.

HanneSThEGreaT
September 3rd, 2009, 08:35 AM
OK, no prob :).

Last question ( sorry for all these questions, I'm just trying to narrow down the issue )
Does it always happen with the same column, or does it happen with any of these columns ¿

PeejAvery
September 3rd, 2009, 08:58 AM
Can happen on any column so long as the asc/desc is changed.

dglienna
September 3rd, 2009, 06:21 PM
Can you explain this a little better?

* If I click a column so that it sorts, I receive the error.
* However, if I click another column so that the sort order (asc, desc) is the same, but the column is different, I don't see the error again.
* But, it seems that the moment asc or desc is changed, that's when I receive the error.



Sort EMAIL to ASC. Error
Change NAME ... ? (was unsorted before, right)

Thanks