Stringgrid mit Quickreport drucken
-
Hallo,
Ich benutze zum erstenmal Quickreport, hat jemand von Euch eine Idee wie ich 2 Stringgrids auslese und auf Papier bringe.
Ein Stringgrid funktioniert mit dem Code unten ohne Probleme. Es handelt sich dabei nicht um eine Datenbank Anwendung.
Mein Ansatz fuer ein Stringgrid:void __fastcall TForm1::DetailBand1BeforePrint(TQRCustomBand *Sender,
bool &PrintBand)
{
String a = Form1->StringGrid1->Cells[1][n];
String b = Form1->StringGrid1->Cells[2][n];
String c = Form1->StringGrid1->Cells[3][n];
QRLabel1->Caption = a;
QRLabel2->Caption = b;
QRLabel3->Caption = c;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::DetailBand1AfterPrint(TQRCustomBand *Sender,
bool BandPrinted)
{
n++;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::QuickRep1NeedData(TObject *Sender, bool &MoreData)
{
if ( n == 5) // 5 ist z.B. die Anzahl der Zeilen
{
MoreData = false;
}
else
MoreData = true;
}
//---------------------------------------------------------------------------void __fastcall TForm1::QuickRep1BeforePrint(TCustomQuickRep *Sender,
bool &PrintReport)
{
n = 0;
}
-
ungefähr so:
void __fastcall TForm1::DetailBand1BeforePrint(TQRCustomBand *Sender, bool &PrintBand) { String a; String b; String c; if (n <= Form1->StringGrid1->RowCount) { String a = Form1->StringGrid1->Cells[1][n]; String b = Form1->StringGrid1->Cells[2][n]; String c = Form1->StringGrid1->Cells[3][n]; } else { a = Form1->StringGrid2->Cells[1][n-Form1->StringGrid1->RowCount]; b = Form1->StringGrid2->Cells[2][n-Form1->StringGrid1->RowCount]; c = Form1->StringGrid2->Cells[3][n-Form1->StringGrid1->RowCount]; } QRLabel1->Caption = a; QRLabel2->Caption = b; QRLabel3->Caption = c; } //--------------------------------------------------------------------------- void __fastcall TForm1::DetailBand1AfterPrint(TQRCustomBand *Sender, bool BandPrinted) { n++; } //--------------------------------------------------------------------------- void __fastcall TForm1::QuickRep1NeedData(TObject *Sender, bool &MoreData) { if ( n == Form1->StringGrid1->RowCount + Form1->StringGrid2->RowCount) // 5 ist z.B. die Anzahl der Zeilen { MoreData = false; } else MoreData = true; } //--------------------------------------------------------------------------- void __fastcall TForm1::QuickRep1BeforePrint(TCustomQuickRep *Sender, bool &PrintReport) { n = 0; }
-
Hi,
nur OnNeedData
void __fastcall TForm2::QuickRep1NeedData(TObject *Sender, bool &MoreData) { static int TmpRow = 0; MoreData = ++TmpRow < Form1->StringGrid1->RowCount; if (MoreData) { QRLabel1->Caption = Form1->StringGrid1->Cells[1][TmpRow]; QRLabel2->Caption = Form1->StringGrid1->Cells[2][TmpRow]; QRLabel3->Caption = Form1->StringGrid1->Cells[3][TmpRow]; } else TmpRow = 0; }
hier ist Beispiel -> ListView[vsReport]
http://www.windev.cz/data/clanky/qreport_lv.zip
http://www.windev.cz/index.aspx?clanek=qreport_lv.htm
-
Dank Euch, klappt wunderbar !