Hola.
En tu código, el único lugar donde usas la función
IndexOf es en la línea:
Código Delphi
[-]
...
Fventa.SGVenta.Row := Fventa.SGVenta.Cols[1].indexOf(scve);
...
Pero... el error no puede provocarlo la función
IndexOf ya que ella devuelve la posición en base cero, o -1 de no encontrar una ocurrencia. Por lo tanto el error debe ser provocado por el valor del índice usado en el
TStrings Cols.
Para verificar (y visualizar) la validez del índice agrega lo siguiente:
Código Delphi
[-]
...
var
inx: Integer;
begin
inx := 1;
texto:=FVenta.EdVenta.Text;
IF GetTokenCount(texto,'%') = 2 then
begin
if (EsStrunNumero(GetToken(texto,'%',1))) and (EsStrunNumero(GetToken(texto,'%',2)))then
begin
idesc:= StrToInt(GetToken(texto,'%',1));
scve:= GetToken(texto,'%',2);
if inx > SGVenta.ColCount-1 then
raise Exception.CreateFmt('¡ Indice %d fuera de rango !%sSólo existen %d columnas',
[inx, #13#10, SGVenta.ColCount-1]);
Fventa.SGVenta.Row := Fventa.SGVenta.Cols[inx].indexOf(scve);
...
Saludos