1、设置QuickReport的DataSet为空。
2、在QuickReport的BeforePrint里面将要显示的数据集合初始化,如Query1.First;
3、在OnNeedData里面写代码,同时设置MoreData的状态、移动数据集合
如:QrLabel1.Caption:=Query1.FieldByName('Col1').AsString;
Query1.Next;
MoreData:=Not Query1.Eof;
这样就OK了!

https://wedelphi.com/t/92391/

quickreport 的 OnNeedData:
procedure TForm1.QuickRep1NeedData(Sender: TObject;
var MoreData: Boolean);
begin
moredata:=true;
if not table1.Eof then
begin
begin
qrlabel1.Caption := table1.fieldbyname('Name').AsString;
//subDetail中要显示的数据
qrlabel2.Caption := table1.fieldbyname('Age').AsString;
end;
table1.Next;
end
else
//每页显示五行,不足用空行补齐
if nRow < 5 then
begin
qrlabel1.Caption := '';
qrlabel2.Caption := '';
end;
if nRow = 5 then
begin
moredata := false;
table1.First;
nRow := 0;
end;
Inc(nRow);
end;

https://wedelphi.com/t/302356/

如果你有quickreport的源代码可以这样改造,下面代码是需要加入的。
由于这里不一定说的清楚,你如果写过控件可以自己改造,代码就这些,
如果不行可以和我单独交流:  TQrCustomController = class(TComponent) {控制}
private
    FDetailPerPage: integer;
    procedure SetDeatilPerPage(APerPage: integer);
public
      property DetailPerPage: integer read FDetailPerPage write   SetDeatilPerPage;
end;
TCustomQrReport = class(TQrBasePanel)
private
    FDetailPerPage: integer;
    procedure SetDeatilPerPage(APerPage: integer);
public
    procedure PrintBandchildNone(ABand: TNoteCustomBand); {打印但没有孩子}
    property DetailPerPage: integer read FDetailPerPage write SetDeatilPerPage;
end;
procedure TCustomNotePaint.PrintBandchildNone(ABand: TNoteCustomBand);
{打印但没有孩子}
var
  dmy: integer;
begin
  if ABand <> nil then
  begin
    if ABand.AlignToBottom then
    begin
      if Page.Orientation = poPortrait then
        dmy := round(QRPrinter.PaperLength - Page.BottomMargin -
          ABand.Size.Length - FPageFooterSize)
      else
        dmy := round(QRPrinter.PaperWidth - Page.BottomMargin -
          ABand.Size.Length - FPageFooterSize);
      if dmy > CurrentY then
        CurrentY := dmy;
    end;
    ABand.PrintNoChild;
  end;
end;
//加入固定数目的空白行procedure TQrController.PrintBlankFooter(Anum: integer);
var
  I, j: integer;
  TmpBand: TNoteband;
  TmpColor: tColor;
begin
  if Anum = 0 then
    exit;
  if Anum = FDetailPerPage then
    exit;
  TmpBand := TQrBand.Create(FParentReport);
  TmpBand.BandType := rbSummary;
  TmpBand.Frame.DrawLeft := true;
  TmpBand.Frame.DrawRight := true;
  TmpBand.Frame.DrawBottom := true;
  if ((FDetail <> nil) and (FDetail.ControlCount > 0)) then
    TmpColor := TQrCustomLabel(FDetail.Controls[0]).Font.Color;
  for I := Anum - 1 downto 0 do
  begin
    for j := 0 to FDetail.ControlCount - 1 do
    begin
      TQrCustomLabel(FDetail.Controls[j]).Font.Color := FDetail.Color;
      {颜色为底色}
    end;
    FParentReport.PrintBandchildNone(FDetail);
    {有效但造成了最后一条记录的重复计算,修改后已经解决}
    for j := 0 to FDetail.ControlCount - 1 do
    begin
      TNoteCustomLabel(FDetail.Controls[j]).Font.Color := TmpColor;
    end;
  end;
  TmpBand.Free;
end;
///Suny modified 2000.3.15 one functionprocedure TQrCustomController.SetDeatilPerPage(APerPage: integer);
begin
  FDetailPerPage := APerPage;
end;///Suny modified 2000.3.15 one functionprocedure TCustomQrReport.SetDeatilPerPage(APerPage: integer);
begin
  FDetailPerPage := APerPage;
  Controller.DetailPerPage := AperPage;
end;
在procedure TQrController.Execute;函数中找到:
          ParentReport.QRPrinter.Progress := (Longint(DetailNumber) * 100) div
            RecCount;
一句,在其后加入
        if FDetailPerPage <> 0 then
        begin
          if (FDetailNumber mod FDetailPerPage) = 0 then
          begin
            if assigned(FFooter) then
            begin
              if (SelfCheck is TCustomNotePaint) and
                FFooter.AlignToBottom then
                ;
              // ParentReport.FPageFooterSize := 0;
              if (FFooter <> nil) and (ParentReport.PageNumber = 0) then
                ParentReport.NewPage;
              ParentReport.PrintBand(FFooter);
            end;再找到:
      CheckLastGroupFooters;
      PrintGroupFooters;
      if assigned(FFooter) then
      begin
        if (SelfCheck is TCustomNotePaint) and
          FFooter.AlignToBottom then
          ;
在其前加入:
      if FDetailPerPage <> 0 then
        if detailNumber = RecCount then
          PrintBlankFooter(FDetailPerPage - (RecCount mod FDetailPerPage));

http://www.debugease.com/delphi/4231392.html

QuickReport的OnNeedData的触发情况的更多相关文章

  1. 关于Application_End 与 Application_Start事件触发情况的测试(待续)

    测试项目搭建 定义一个简单的Mvc项目,有如下文件: (1) public class Startup { public void Configuration(IAppBuilder app) { a ...

  2. 触发Full GC执行的情况

    除直接调用System.gc外,触发Full GC执行的情况有如下四种. 1. 旧生代空间不足 旧生代空间只有在新生代对象转入及创建为大对象.大数组时才会出现不足的现象,当执行Full GC后空间仍然 ...

  3. GC之三--GC 触发Full GC执行的情况及应对策略

    1.System.gc()方法的调用 此方法的调用是建议JVM进行Full GC,虽然只是建议而非一定,但很多情况下它会触发 Full GC,从而增加Full GC的频率,也即增加了间歇性停顿的次数. ...

  4. 触发JVM进行Full GC的情况及应对策略

    堆内存划分为 Eden.Survivor 和 Tenured/Old 空间,如下图所示: 从年轻代空间(包括 Eden 和 Survivor 区域)回收内存被称为 Minor GC,对老年代GC称为M ...

  5. 触发Full GC执行的情况 以及其它补充信息

    除直接调用System.gc外,触发Full GC执行的情况有如下四种.1. 旧生代空间不足旧生代空间只有在新生代对象转入及创建为大对象.大数组时才会出现不足的现象,当执行Full GC后空间仍然不足 ...

  6. GC之八--GC 触发Full GC执行的情况及应对策略

    目录: GC之一--GC 的算法分析.垃圾收集器.内存分配策略介绍 GC之二--GC日志分析(jdk1.8)整理中 GC之三--GC 触发Full GC执行的情况及应对策略 gc之四--Minor G ...

  7. java触发full gc的几种情况概述

    前言 近期被问及这个问题,在此记录整理一下. System.gc()方法的调用 此方法的调用是建议JVM进行Full GC,虽然只是建议而非一定,但很多情况下它会触发 Full GC,从而增加Full ...

  8. Delphi ComboBox的属性和事件、及几个鼠标事件的触发

    临时做了两个小的测试程序,为了彻底弄清楚combobox的OnClick.OnChange.OnDropDown.OnCloseUp.OnSelect事件的触发及其先后顺序. 另附常用鼠标事件的触发情 ...

  9. JVM-触发Full GC的情况

    除直接调用System.gc外,触发Full GC执行的情况有如下四种: 1.老年代空间不足 老年代空间只有在新生代对象转入及创建为大对象.大数组时才会出现不足现象,当执行Full GC后空间仍然不足 ...

随机推荐

  1. ios开发网络学习五:输出流以及文件上传

    一:输出流 #import "ViewController.h" @interface ViewController ()<NSURLConnectionDataDelega ...

  2. tig install ncursesw

    ./configure --prefix=/home/xxx/.local/ --with-ncursesw make[xxx$ ldd src/tig linux-vdso.so.1 => ( ...

  3. [Angular] NgRx/effect, why to use it?

    See the current implementaion of code, we have a smart component, and inside the smart component we ...

  4. ASP.NET 生命周期及管道事件

    Client(发送报文:请求行+请求头+空行+请求体) <------ Http 协议 ------> Server,由 Http.sys 监听 Http 请求 -> WAS+Met ...

  5. C++ 工具类 —— 词条类(Entry)

    Entry 以键值对(key-value pair)的形式定义. template <typename K, typename V> struct Entry{ K key; V valu ...

  6. VO对象通过groovy模板映射XML文件

    介绍 之前写过JAVA+XSLT相关的技术博客,近期研究了一个开源工具包org.codehaus.groovy,处理VO对象和XML文件映射很方便. 简言之:将VO对象中的属性(包含Collectio ...

  7. ets学习

    http://diaocow.iteye.com/blog/1768647 http://www.cnblogs.com/me-sa/archive/2011/08/11/erlang0007.htm ...

  8. QT类库与Delphi VCL类库的体系结构对比——两者十分类似!

    今天在看QT对象内存管理的一篇文章时:http://blog.csdn.net/dbzhang800/article/details/6300025想到了一个问题:就是QT类库体系结构与Delphi类 ...

  9. 瀑布流的一些CSS实现方式

    一个选择是用CSS3的多列columns,可以参考这篇文章.但这篇文章给的例子并不怎么好理解,我做了一些更改,在每个元素上加了序号.可以看到,多列布局是在每一列上依次排列元素的,第一列排完才开始排第二 ...

  10. 哪个项目管理工具好用到哭?JIRA VS 华为软件开发云

    一.产品介绍 JIRA是Atlassian公司出品的项目与事务跟踪工具,被广泛应用于缺陷跟踪.客户服务.需求收集.流程审批.任务跟踪.项目跟踪和敏捷管理等工作领域. 华为软件开发云 (DevCloud ...