If there are 3
rows, then they are called
0, 1, 2.
Notice that there is no row called 3
.
More generally, if there are N
rows, then they are called
0, 1, 2, ..., N - 1.
Notice that there is no row called N
.
Hence, your problem can be found already on the first line of your question:
i [sic!] have a string grid in Delphi 7, with N rows. There is a listbox with numbers from 0..N
If there are N
rows, then the listbox should contain the numbers 0..N-1
. Indeed, if you let it contain the numbers 0..N
, then the number of lines in the listbox will equal N+1
, i.e., one more than the number of items in the string grid.
Also: I'd do simply
StringGrid1.Selection := TGridRect(Rect(0, 3, 4, 3))
to select the row with index 3
, assuming the number of columns is 4+1