Try it:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
QuickReport2.WantToPreview := True;
QuickReport2.Preview;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
QuickReport2.WantToPreview := False;
QuickReport2.Print;
end;
end.
unit Unit2;
interface
uses Windows, SysUtils, Messages, Classes, Graphics, Controls,
StdCtrls, ExtCtrls, Forms, QuickRpt, QRCtrls;
type
TQuickReport2 = class(TQuickRep)
QRBand1: TQRBand;
QRLabel1: TQRLabel;
procedure QRBand1BeforePrint(Sender: TQRCustomBand;
var PrintBand: Boolean);
procedure QRLabel1Print(sender: TObject;
var Value: String);
private
FWantToPreview: Boolean;
public
property WantToPreview: Boolean write FWantToPreview;
end;
var
QuickReport2: TQuickReport2;
implementation
{$R *.DFM}
procedure TQuickReport2.QRBand1BeforePrint(Sender: TQRCustomBand;
var PrintBand: Boolean);
begin
with QRBand1.Framedo
begin
DrawTop := FWantToPreview;
DrawLeft := FWantToPreview;
DrawBottom := FWantToPreview;
DrawRight := FWantToPreview;
end;
end;
procedure TQuickReport2.QRLabel1Print(sender: TObject;
var Value: String);
begin
if not FWantToPreview then
Value := '';
end;
end.