i have a string grid in Delphi 7, with 0..N rows. There is a listbox with numbers from 0..N if the user clicks on the any number in the listbox number , that row number should be selected on the stringgrid.
so i have this
MystringGrid.Col :=0;
MystringGrid.Row :=Listbox.itemindex;
MystringGrid.Selection:=TGridRect(Rect(0,1 ,1 ,1));
MystringGrid.SetFocus;
This will nicely select the row on the grid (highlight it) but the problem is if
listbox.itemindex=MystringGrid.rowcount;
That time i get
Grid Index out of range error
as in grids.pas
if (ACol < 0) or (ARow < 0) or (ACol >= ColCount) or (ARow >= RowCount) then
InvalidOp(SIndexOutOfRange)
(ARow >= RowCount)
is true so error
how do i select the last row?