Results 1 to 8 of 8

Thread: error "Index was outside the bounds of the array"

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2001
    Posts
    8

    error "Index was outside the bounds of the array"

    I have a datatgrid with datasource of type Dataset (connected by SetDataBinding(ds, table_name).

    Sometimes when I click on a row (uaually after resize a column or scroll the grid), I get this error message: "Index was outside the bounds of the array",
    and the debugger points of the declaration of the form that starts the project.

    Why is it happens and how to avoid this?

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Are you running in Debug mode or Release mode?
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2001
    Posts
    8

    on debug mode

    and by the way: I'm not deleteing any row from the dataset.

  4. #4
    Hyperactive Member
    Join Date
    Mar 2004
    Location
    Prato - Tuscany - Italy
    Posts
    461
    Because you speak about debugger, I think you are in debug mode. Anyway debugger is often very stupid. Not always it indicates the row where error is fired. You have to look at what in the italian version you could find clicking on 'Dettagli' (I suppose Details in english version) if the button is available, if so, you can assume the last rownumber you can read (the one at the top) is the real row number where error occurs. This is only my experience, but until now it has always revealed true!
    Good job!
    Live long and prosper (Mr. Spock)

  5. #5

    Thread Starter
    New Member
    Join Date
    Feb 2001
    Posts
    8

    There is no 'Details' button in this case

    I know what you mean, because I saw this button in many error messages before, but in this case the error message does not contain this button.

    Doesn't anyone knows this datagrid problem?

  6. #6

    Thread Starter
    New Member
    Join Date
    Feb 2001
    Posts
    8

    I found the code that cause the problem

    But I still don't understand why!

    it's:

    Dim hi As System.Windows.Forms.DataGrid.HitTestInfo
    hi = datagrid1.HitTest(e.X, e.Y)
    datagrid1.CurrentRowIndex = hi.Row

    I get the error after resizing a grid column, and then click any grid cell.

  7. #7
    Hyperactive Member
    Join Date
    Mar 2004
    Location
    Prato - Tuscany - Italy
    Posts
    461
    In fact...this is why I wrote 'if the button is available'
    I saw, also that in the most of case (or always...I'm not sure ), an error occurred in a modal form, put the debbugger at ...showdialog.. line of code, not within the form. Very stupid!
    Again... when you are stepping through the code ( F8 ), event routine, like FormClosing or Button.PerformClick, are executed in one shot and you can't follow their code if you don't put a breakpoint in their code. I don't know if there is some setting to change this behaviour

    Anyway, I'm afraid but I have never used a datagrid, so I can't analyze your code

    Good job and let's hope someone more experienced could help you, dear friend.
    Live long and prosper (Mr. Spock)

  8. #8

    Thread Starter
    New Member
    Join Date
    Feb 2001
    Posts
    8

    Smile thanks for your effort


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width