Inserrer le resultat d'une requete dans un stringgrid

Résolu
cs_tgr74 Messages postés 23 Date d'inscription jeudi 22 mars 2007 Statut Membre Dernière intervention 26 août 2009 - 12 sept. 2008 à 11:49
f0xi Messages postés 4205 Date d'inscription samedi 16 octobre 2004 Statut Modérateur Dernière intervention 12 mars 2022 - 12 sept. 2008 à 11:56
Bonjour à tous,
j'ai besoin de votre aide pour charger les données d'une requête de sélection dans un stringgrid.
j'ai déjà essayer  le code suivant mais le résultat n'est pas bon. merci de votre prompte réaction.

var i,j : integer;
begin
 softbankdata.SelectionBillet;
 softbankdata.qryBillet.Last;
 c:=softbankdata.qryBillet.RecordCount;
 softbankdata.qryBillet.First;
 while not softbankdata.qryBillet.Eof   do
 begin
 With StringGrid1 do
 begin
      RowCount := c;
      ColCount :=3;

     Cells[0,0]:='Valeur';
     Cells[1,0]:='Libelle';
     Cells[2,0]:='Nombre';

     //for j:=1 to RowCount-1 do
     //Cells[0,j]:=floattostr(softbankdata.qryBilletVALEUR.Value);

     //for j:=1 to RowCount-1 do
     //Cells[1,j]:=softbankdata.qryBilletLIBELLE.Value;

     //for j:=1 to RowCount-1 do
     //Cells[2,J]:=floattostr(softbankdata.qryBilletNOMBRE.Value);

     end;
    softbankdata.qryBillet.Next;
  end;
end;
Tgr74

1 réponse

f0xi Messages postés 4205 Date d'inscription samedi 16 octobre 2004 Statut Modérateur Dernière intervention 12 mars 2022 35
12 sept. 2008 à 11:56
logiquement tu devrait avoir ceci :

var J,C : integer;
begin
 softbankdata.SelectionBillet;
 softbankdata.qryBillet.Last;
 C := softbankdata.qryBillet.RecordCount;
 softbankdata.qryBillet.First;

 StringGrid1.RowCount := C;
 StringGrid1.ColCount := 3;
 StringGrid1.Cells[0,0]:='Valeur';
 StringGrid1.Cells[1,0]:='Libelle';
 StringGrid1.Cells[2,0]:='Nombre';
 
 J := 1;
 while (not softbankdata.qryBillet.Eof) or (J <= C) do
 begin
   StringGrid1.Cells[0,J] := format('%n',[softbankdata.qryBilletVALEUR.Value]);
   StringGrid1.Cells[1,J] := softbankdata.qryBilletLIBELLE.Value;
   StringGrid1.Cells[2,J] := format('%n',[softbankdata.qryBilletNOMBRE.Value]);
   softbankdata.qryBillet.Next;
   inc(J);
 end;
end;

3
Rejoignez-nous