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. tplink-如何远程WEB管理路由器?

    http://service.tp-link.com.cn/detail_article_185.html 如何远程WEB管理路由器? 新版tplink怎么远程Web管理? https://www.1 ...

  2. 切换-5.7-GTID复制切换成传统复制

    mysql5.7 gtid和传统复制在线切换,5.7.6 之后 不用重启可以直接在线切换   基本环境   Master Slave MySQL版本 MySQL-5.7.16-X86_64 MySQL ...

  3. web项目中配置多个数据源

    web项目中配置多个数据源 spring + mybatis 多数据源配置有两种解决方案 1.配置多个不同的数据源,使用一个sessionFactory,在业务逻辑使用的时候自动切换到不同的数据源,  ...

  4. 新技能 get —— 使用 python 生成词云

    什么是词云(word cloud)呢?词云又叫文字云,是对文本数据中出现频率较高的"关键词"在视觉上的突出呈现,形成关键词的渲染形成类似云一样的彩色图片,从而一眼就可以领略文本数据 ...

  5. 【29.89%】【codeforces 734D】Anton and Chess

    time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  6. ssh远程连接docker中的 linux container

    ssh远程连接docker中的container   由于工作需要,要远程连接Container,本地机器是windows,以下为解决步骤: 1. 环境 本地:Windows ↓ Docker版本1. ...

  7. Android中自定义View和自定义动画

    Android FrameWork 层给我们提供了很多界面组件,但是在实际的商业开发中这些组件往往并不能完全满足我们的需求,这时候我们就需要自定义我们自己的视图和动画. 我们要重写系统的View就必须 ...

  8. 【24.63%】【codefroces 686D】Kay and Snowflake

    time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standa ...

  9. 让delphi2010操作界面回到delphi7模式

    让delphi2010操作界面回到delphi7模式 在使用delphi2010的过程中,很不习惯它的窗口在一个框框内,感觉很不方便,可能是因为使用delphi7很多年了,已经习惯了delphi7的版 ...

  10. spring-boot-starter-parent 1.3.6.RELEASE

    2016-11-17 23:43:17.979 DEBUG 3944 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Creating share ...