好啊,下面是代码,我加了一个按钮,一点击按钮就预览。多谢了!
unit PhcePrint;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
QuickRpt, Qrctrls, Db, DBTables, ExtCtrls, StdCtrls, Buttons;
type
TFormPhcePrint = class(TForm)
QuickRep1: TQuickRep;
Table1: TTable;
DataSource1: TDataSource;
BitBtn1: TBitBtn;
ColumnHeaderBand1: TQRBand;
QRLabel1: TQRLabel;
QRLabel2: TQRLabel;
QRLabel3: TQRLabel;
QRLabel4: TQRLabel;
QRLabel5: TQRLabel;
QRLabel6: TQRLabel;
QRLabel7: TQRLabel;
QRLabel8: TQRLabel;
PageHeaderBand1: TQRBand;
QRLabel9: TQRLabel;
QRLabel10: TQRLabel;
QRSysData1: TQRSysData;
QRLabel11: TQRLabel;
QRLabel12: TQRLabel;
DetailBand2: TQRBand;
QRDBText1: TQRDBText;
QRDBText2: TQRDBText;
QRDBText3: TQRDBText;
QRDBText4: TQRDBText;
QRDBText5: TQRDBText;
QRDBText6: TQRDBText;
QRLabel13: TQRLabel;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure QRLabel13Print(sender: TObject;
var Value: String);
procedure QuickRep1BeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FormPhcePrint: TFormPhcePrint;
implementation
{$R *.DFM}
procedure TFormPhcePrint.FormCreate(Sender: TObject);
begin
Table1.Active:=True;
// QuickRep1.QRLabel13.Caption:=QuickRep1.QrPrinter.PageCount
// QuickRep1.QRLabel13.Caption:=inttostr(nPageCount);
// QuickRep1.Preview;
BitBtn1.Click;
// FormPhcePrint.Close();
end;
procedure TFormPhcePrint.QRLabel13Print(sender: TObject;
var Value: String);
begin
Caption:=inttostr(QuickRep1.QrPrinter.PageCount);
end;
procedure TFormPhcePrint.QuickRep1BeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
begin
QRLabel13.Caption:=IntToStr(QuickRep1.QrPrinter.PageCount);
end;
procedure TFormPhcePrint.Button1Click(Sender: TObject);
begin
QuickRep1.Prepare;
QRLabel13.Caption:=IntToStr(QuickRep1.QrPrinter.PageCount);
QuickRep1.Preview;
end;
end.