Hola.
No entiendo bien tu dificultad, pero hice una prueba con los valores que indicas en tu mensaje:
Cita:
156|56|183|56|214|56|238|56|
|
y no me dió ningún problema.
El código de la prueba:
Código Delphi
[-]
...
implementation {$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
const
VP: array[0..3] of string = ('156','183','214','238');
var
sg: TStringGrid;
cv: TCanvas;
i : Integer;
begin
sg := StringGrid1;
sg.FixedCols := 0;
sg.FixedRows := 0;
sg.ColCount := 2;
sg.RowCount := 4;
cv := Image1.Picture.Bitmap.Canvas;
for i := 0 to 3 do
begin
cv.Pixels[StrToInt(VP[i]), 56] := clRed;
sg.Cells[0, i] := VP[i];
sg.Cells[1, i] := '56';
end;
end;
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
dx, dy, r : Integer;
sg: TStringGrid;
begin
sg := StringGrid1;
for r := 0 to StringGrid1.RowCount - 1 do
begin
dx := X - (StrToInt(StringGrid1.Cells[0, r]));
dy := Y - (strToInt(StringGrid1.Cells[1, r]));
if (abs(dx) < 5) and (abs(dy) < 5) then
begin
sg.Selection := TGridRect(Rect(0, r, sg.ColCount, r));
Label1.Caption := 'Encontrado en renglon ' + inttostr(r);
end;
end;
end;
...
Salida:
La única situación en que se me ocurre que podría haber confusión es cuando se solapen los valores de X e Y dada la tolerancia de 5 píxeles que les das.
Saludos