定义几个变量就可以了,在每行打印前先比较变量和对应字段的值是不是一样,
相等则qrdbtext.enabled := False ,不等则qrdbtext.enabled := True,
在每行打印后对字段附值.
unit Unit2;
interface
uses Windows, SysUtils, Messages, Classes, Graphics, Controls,
StdCtrls, ExtCtrls, Forms, Quickrpt, QRCtrls;
type
TQuickReport2 = class(TQuickRep)
QRBandtitle: TQRBand;
Query1: TQuery;
QRBandDetails: TQRBand;
QRDBText2: TQRDBText;
QRDBText3: TQRDBText;
QRDBText1: TQRDBText;
procedure QRBandDetailsBeforePrint(Sender: TQRCustomBand;
var PrintBand: Boolean);
procedure QRBandDetailsAfterPrint(Sender: TQRCustomBand;
BandPrinted: Boolean);
private
Sfield1,SField2:String
public
end;
var
QuickReport2: TQuickReport2;
implementation
{$R *.DFM}
procedure TQuickReport2.QRBandDetailsBeforePrint(Sender: TQRCustomBand;
var PrintBand: Boolean);
begin
If Sfield1<>QuickReport2.dataset.fieldByname('Field1').asstring then
QRDBText1.enabled :=True
else
QRDBText1.enabled :=False;
If Sfield2<>QuickReport2.dataset.fieldByname('Field2').asstring then
QRDBText2.enabled :=True
else
QRDBText2.enabled :=False;
end;
procedure TQuickReport2.QRBandDetailsAfterPrint(Sender: TQRCustomBand;
BandPrinted: Boolean);
begin
Sfield1:=QuickReport2.dataset.fieldByname('Field1').asstring;
Sfield2:=QuickReport2.dataset.fieldByname('Field2').asstring;
end;
end.