Lenny, tengo un ejemplo que pasa el resultado de una consulta a un stringgrid, espero te sirva
este ejemplo toma los datos de una consulta (queryex2) y los pasa a un string grid.
se me ocurre que al momento de darle doble clic al registro en tu primer grid generes una consulta con la clave de ese registro y posteriormente llenes la segunda grid con los datos que te resulten de esa consulta.
Código Delphi
[-]
procedure TFORMCAJACHICA.CONSTRUYECREDITOClick(Sender: TObject);
var
i,x:Integer; r: real;
begin
for I := 1 to StringGrid1.RowCount - 1 do
StringGrid1.Rows[i].Clear;
stringgrid1.Rowcount:=(queryex2.recordcount + 5); stringgrid1.ColCount:=12;
with StringGrid1 do
begin
Cells[0, 0] := '';
Cells[1, 0] := 'FOLIO';
Cells[2, 0] := 'FECHA';
Cells[3, 0] := 'CHOFER';
Cells[4, 0] := 'GRUA';
Cells[5, 0] := 'CLIENTE';
Cells[6, 0] := 'SERVICIO';
Cells[7, 0] := 'SUBTOTAL';
Cells[8, 0] := 'I.V.A.';
Cells[9, 0] := 'RET.';
Cells[10, 0] := 'TOTAL';
Cells[11, 0] := 'FACTURA';
end;
stringgrid1.ColWidths[0]:=25;
stringgrid1.ColWidths[1]:=70;
stringgrid1.ColWidths[2]:=80;
stringgrid1.ColWidths[3]:=70;
stringgrid1.ColWidths[4]:=60;
stringgrid1.ColWidths[5]:=280;
stringgrid1.ColWidths[6]:=105;
stringgrid1.ColWidths[7]:=70;
stringgrid1.ColWidths[8]:=70;
stringgrid1.ColWidths[9]:=70;
stringgrid1.ColWidths[10]:=70;
stringgrid1.ColWidths[11]:=70;
x:=1;
queryEX2.first;
while not (queryEX2.eof) do
begin
with StringGrid1 do
begin
Cells[0, x] := '';
if QUERYEX2.fieldvalues['folio']=null then
Cells[1, x] := ''
else
Cells[1, x] :=QUERYEX2.fieldvalues['folio'];
if (QUERYEX2.FieldValues['FECHA'] <> null) then
begin
Present:= QUERYEX2.FieldValues['FECHA'];
DecodeDate(Present, Year, Month, Day);
case month of
1: mes := 'Ene';
2: mes := 'Feb';
3: mes := 'Mar';
4: mes := 'Abr';
5: mes := 'May';
6: mes := 'Jun';
7: mes := 'Jul';
8: mes := 'Ago';
9: mes := 'Sep';
10: mes := 'Oct';
11: mes := 'Nov';
12: mes := 'Dic';
end;
Cells[2, x] := IntToStr(Day) + '-' + mes + '-' + IntToStr(Year);
end;
if QUERYEX2.fieldvalues['cHOFER']=null then
Cells[3, x] := ''
else
Cells[3, x] :=(QUERYEX2.fieldvalues['CHOFER']);
if QUERYEX2.fieldvalues['GRUA']=null then
Cells[4, x] := ''
else
Cells[4, x] :=(QUERYEX2.fieldvalues['GRUA']);
if QUERYEX2.fieldvalues['ASEG']=null then
Cells[5, x] := ''
else
Cells[5, x] :=(QUERYEX2.fieldvalues['ASEG']);
if QUERYEX2.fieldvalues['TIPO2']=null then
Cells[6, x] := ''
else
Cells[6, x] :=(QUERYEX2.fieldvalues['TIPO2']);
if ((QUERYEX2.fieldvalues[sub]=null) OR (QUERYEX2.fieldvalues[sub]=0))then
Cells[7, x] := ''
else
begin
r:= queryex2.fieldvalues[sub];
Cells[7, x] :=Format('%0:2f',[r]);
end;
if ((QUERYEX2.fieldvalues['IVA']=null) OR (QUERYEX2.fieldvalues['IVA']=0))then
Cells[8, x] := ''
else
begin
r:= queryex2.fieldvalues['IVA'];
Cells[8, x] :=Format('%0:2f',[r]);
end;
if ((QUERYEX2.fieldvalues['IMPRET']=null) OR (QUERYEX2.fieldvalues['IMPRET']=0))then
Cells[9, x] := ''
else
begin
r:= queryex2.fieldvalues['IMPRET'];
Cells[9, x] :=Format('%0:2f',[r]);
end;
if ((QUERYEX2.fieldvalues['IMPNETO']=null) OR (QUERYEX2.fieldvalues['IMPNETO']=0))then
Cells[10, x] := ''
else
begin
r:= queryex2.fieldvalues['IMPNETO'];
Cells[10, x] :=Format('%0:2f',[r]);
end;
if QUERYEX2.fieldvalues['fac']=null then
Cells[11, x] := ''
else
Cells[11, x] :=(QUERYEX2.fieldvalues['fac']);
Inc(x);
end;
queryEX2.Next;
end;
StringGrid1.Row:=X;
end;
este ejemplo lo tengo en delphi 7. componentes zeos Mysql 5.0
cualquier cosa que no entiendas me avisas.
