Follow the code:
procedure TfrmGrid.sgCuponsDblClick(Sender: TObject);
var
txt: TextFile;
l, i : integer;
lTemp, CFF, COO: String;
begin
i:=0;
l:=0;
CFF := sgCupons.Cells[0,sgCupons.Row];
COO := sgCupons.Cells[1,sgCupons.Row];
AssignFile(txt, lbCaminho.Caption);
Reset(txt);
while not eof(txt) do
begin
Readln(txt, lTemp);
if (copy(lTemp, 1, 3) = 'E15')
and (copy(lTemp,47,6 = CFF))
and (copy(lTemp,53,6) = COO)
then
begin
inc(i);
sgItens.RowCount:=i;
ShowMessage(CFF+' '+COO);
end;
end;
CloseFile(txt);
ShowMessage('Existem '+IntToStr(i)+' linhas.');
if (sgCupons.Row <> 0) then
begin
AssignFile(txt, lbCaminho.Caption);
Reset(txt);
while not eof(txt) do
begin
Readln(txt, lTemp);
if (copy(lTemp, 1, 3) = 'E15')
and (copy(lTemp,47,6) = CFF)
and (copy(lTemp,53,6) = COO)
then
begin
sgItens.Enabled := True;
inc(l);
//Ordem
//sgItens.Cells[0,l] := copy();
//Codigo
sgItens.Cells[1,l] := copy(lTemp,62 ,14);
//Descricao
sgItens.Cells[2,l] := copy(lTemp,76, 100);
//Qtde
sgItens.Cells[3,l] := copy(lTemp,176, 7);
//Pr. Unitario
sgItens.Cells[4,l] := copy(lTemp, 186, 8);
//Pr. Total
sgItens.Cells[5,l] := copy(lTemp, 210, 14);
//Antiquota
sgItens.Cells[6,l] := copy(lTemp, 0, 0);
end;
end;
CloseFile(txt);
end;
if not (sgCupons.Row <> 0) then
sgItens.Enabled := false;
end;
In fact, something is missing, but I would like you to help me ...
What I want is the following, in the first StringGrid has the Coupons (E14), and the Coupons have subitems (E13), that is, when I double click on a coupon (StringGrid1), the subitems of the selected coupon would go to StringGrid2.
I know it's basically a loop, but does anyone have any suggestions or ideas?
The code informed is of the subitems