设:QuickReport.DataSet=nil;
将QrLabel放在BetailBand里,
在QuickReport的OnNeedData事件里写代码为Qrlabel.Caption赋值,
并控制MoreData属性True,继续打印,False不继续打印
var
vl_PageRow: Integer;
{每页打印的总行数}
vl_CurrentRow: Integer;
{当前打印的行号}
{$R *.DFM}
procedure TForm1.QuickRep1BeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
begin
vl_PageRow := 20;
{第页打印20行}
vl_CurrentRow := 0;
{当前为第0行}
Query1.First ;
end;
procedure TForm1.QuickRep1NeedData(Sender: TObject;
var MoreData: Boolean);
begin
MoreData := vl_CurrentRow = vl_PageRow;
{控制是否继续打印}
{如果数据没打印完,打印数据}
if not Query1.Eof then
begin
with Query1do
begin
QRLabel1.Caption := Fields[0].AsString;
QRLabel2.Caption := Fields[1].AsString;
QRLabel3.Caption := Fields[2].AsString;
Next;
end;
end
else
{数据已批印完成,打印空行}
begin
QRLabel1.Caption := '';
QRLabel2.Caption := '';
QRLabel3.Caption := '';
end;
inc(vl_CurrentRow);
end;