List Index Out of Bounds


I got this error in the current version of TAdvStringGrid ( and the previous version.  This error happens when I do the following.

Load list from DB (605 records)
Filter the list using NarrowDown (value was a 6 character string) from OnSearchEditChange
Delete a row from the filtered list.
Close the form.

In on FormClose, I have Grid.RemoveAllFilters which then triggered the error.

I traced the offending source line to AdvGrid.pas line 18680 in the function UnHideRowList.
Somehow, the variable "j" has become -1 and the List Index Out of Bounds error occurs.

I am using Delphi 2009 Enterprise on Windows 8 Professional.


Sorry, the version for TAdvStringGrid is and the version for TMS Component Pack is


Thanks for reporting. We traced & solved this issue. Next update will address this.

Hi Bruno,

I installed TMS Component Pack and tested the TAdvStringGrid ( with my problem. The listindex error does not show up but I think the changes has mixed up the grid rows slightly. After the call to RemoveFilters, I have missing data in random rows.

This is what I did to reproduce the error.

Load records from DB (622 records)
NarrowDown to 5 rows.
Close form.
In FormClose, call RemoveFilters and dump the contents of Grid to text file

Load records from DB (622 records)
NarrowDown to 5 rows.
Delete last row.
Close Form.
In FormClose, call RemoveFilters and dump the contents of Grid to text file.

Now compare the dump contents.
I have missing data in rows 15, 22, 32, 55, 383, 425, 434,444,616.

Furthermore, the 4 rows that satisfied the NarrowDown after the RemoveRows are no longer in the same
place ( I had the sql query sort alphabetically prior to loading to the grid) and the same  4 rows are repeated
at the end of the grid.

I can send you a copy of my dump files if you need.


It is not supported to remove rows from a filtered grid. It can indeed cause erratic behavior. If you want to remove rows, please first undo the filtering, remove the row and then reapply the filtering.

Hi Bruno,

Is there a function then that will give me the unfiltered row number of the currently selected row so that I can remove the filter and delete the row and reapply the filter? RealRowIndex doesn't seem to work in this case.


Hi Bruno,

Did more testing on RealRowIndex. The first call to RealRowIndex after a NarrowDown will not return the correct value. Since I am reapplying the filter after the Delete, the second time around, RealRowIndex will then return the correct value.