Bonjour,

J'ai un problème avec l'impression de deux StringGrid sur QReport : je n'obtiens pas le résultat souhaité. De plus, je n'ai pas bien compris l'utilisation de la propriété BandType de QRBand (rbTitle, rbSummary, etc.). Du coup, je ne parviens pas à afficher les titres des champs de la 1re StringGrid, puis son contenu, ensuite les titres des champs de la 2e StringGrid et enfin son contenu. Voici le résultat recherché :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
Nom     Prénom
Alain   Dupont
Fabrice Dollet

Numéro  CP    Pays
778     98000 Pays1
879     75432 Pays2
654     56897 Pays3
Sur Form1, j'ai deux StringGrid et un bouton pour lancer l'impression. Et sur Form2, j'ai un QReport sur lequel j'ai mis deux QRBand. QRBand1 contient deux QRLabel et QRBand2 en contient trois.

Voici le code que j'utilise :
Code C++ : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
bool TForm1::Reporter()
{
  if (index > Form1->StringGrid1->RowCount && index > Form1->StringGrid2->RowCount)
  {
        index = 1;
return false;
  }
  else
  {
     if (index <= Form1->StringGrid1->RowCount)
     {
       Form2->QRLabel1->Caption = Form1->StringGrid1->Cells[0][index];
       Form2->QRLabel2->Caption = Form1->StringGrid1->Cells[1][index];
     }
 
     if (index <= Form1->StringGrid2->RowCount)
     {
       Form2->QRLabel3->Caption = Form1->StringGrid2->Cells[0][index];
       Form2->QRLabel4->Caption = Form1->StringGrid2->Cells[1][index];
       Form2->QRLabel5->Caption = Form1->StringGrid2->Cells[2][index];
     }
     index++;
 
    return true;
  }
 
}
 
void __fastcall TForm2::QuickRep1NeedData(TObject *Sender, bool &MoreData)
{
  MoreData = Form1->Reporter();
}
Je vous remercie d'avance pour votre aide.