Forum Discussion

RodrigoJr's avatar
RodrigoJr
Occasional Contributor
6 years ago
Solved

The grid row´s index 20 is out of bounds

I'm having trouble using ClickCell in a Borland TDBGrid,
TestObj.ClickCell (Row, Column, Shift)
you are returning an error message:
'The grid row's index 20 is out of bounds'.
Can anyone help me?

  • I could be wrong, but it sounds like that, even though there are 28 lines in the grid, the rows that are available for cell referencing only number 0-14.  Your code sould take into consideration the visible rows, not the total rows, when determining what row to click on.

4 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Not sure of the rest of the context around that line of code.... where are you assigning the values of Row, Column, etc?

     

    Keep in mind, if you're doing this in a loop where you're basing things off of RowCount or ColumnCount, most grids have the Row and Column value on the cell as zero based.  So, while RowCount may be 20, the last actual Row number is 19.

    • RodrigoJr's avatar
      RodrigoJr
      Occasional Contributor

      the Grid contains 28 lines, only 15 lines are visible, I'm trying to use the clickcell is on line 21 and it returns the error.

      If I click on a line below 15, the problem does not occur...

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        I could be wrong, but it sounds like that, even though there are 28 lines in the grid, the rows that are available for cell referencing only number 0-14.  Your code sould take into consideration the visible rows, not the total rows, when determining what row to click on.