Hola.
No sé si haya otra parte del código que pudiera estar interfiriendo, pero en estas líneas:
Código Delphi
[-]
...
if not ExisteNro(SGFact, FSelProdFact.Edit2.Text, 2) then
begin
end;
...
(*) El código que esta aquí no se ejecuta si FSelProdFact.Edit2.Text es igual a algún valor de la columna 2.
La prueba completa que hice por si te sirviera de algo es:
Código Delphi
[-]
...
procedure TForm1.FormCreate(Sender: TObject);
var
r: Integer;
begin
with StringGrid1 do
begin
FixedCols:= 1;
FixedRows:= 1;
Rowcount := 12;
Rows[0].CommaText:= ' ,1,2,3,4,5'; for r := FixedRows to RowCount-3 do
Cells[2,r]:= FormatFloat('0.0000',r*PI);
Col := 2;
Row := RowCount-2;
Edit1.Text := FormatFloat('0.0000', 3*PI);
end;
end;
function ExisteNro(SG: TStringGrid; const aNum: string; const aCol: Integer): Boolean;
var
r: Integer;
begin
Result := False;
r := SG.FixedRows;
while (r < SG.RowCount-1) and not Result do
begin
Result := SG.Cells[aCol, r] = aNum;
inc(r);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if not ExisteNro(StringGrid1, Edit1.Text, 2) then
StringGrid1.Cells[2, StringGrid1.Row] := Edit1.Text;
end;
...
Saludos