TQRPreview exampleThis example creates a report preview that zooms when the preview window is resized.Steps:1 Choose File|New Form. The only Form setting you need to change for this example is the AutoScroll property. Change it to False. This setting allows the runtime preview to automatically zoom when the form is resized. If you were to leave AutoScroll at True, the preview would always display at the QRPreview component抯 Zoom setting (default 100 percent) when the form is resized. 2 Place components on the form in the order shown below and use the Inspector or indicated instruction to set each component抯 values. Leave other values at their defaults.Component [from palette] Modification Table [DataAccess] DatabaseName property: DBDEMOSTableName property: customer.dbActive property: True QuickRep [QReport] DataSet property: Table1OnPreview event: QuickRep1Preview. The Code editor appears. Type this into the new procedure: QRPreview1.QRPrinter := TQRPrinter(Sender);Return to the form.Right-click the report and choose Send To Back from the popup menu.Double-click the placed report to open the Report Settings dialog. Check the Detail band checkbox, then click OK to create a detail band on the report. QRDBText [QReport] Place this component on the report抯 detail band.DataSet property: Table1DataField property: CompanyAlignToBand property: True Toolbar [Win32] No property changes. Button [Standard] Place this component on the toolbar.Caption property: &PreviewDouble-click the button to open the Code editor window, and enter this for the Button1Click procedure: QuickRep1.Preview; QRPreview [QReport] Place the component anywhere on the form below the toolbar.Align property: alClient 3 Press F9 to run the program. Press the Preview button to load the preview. Note the zoom change as you resize the form.
2 Place components on the form in the order shown below and use the Inspector or indicated instruction to set each component抯 values. Leave other values at their defaults.Component
[from palette]
Modification
Table [DataAccess] DatabaseName property: DBDEMOSTableName property: customer.dbActive property: True
QuickRep [QReport] DataSet property: Table1OnPreview event: QuickRep1Preview. The Code editor appears. Type this into the new procedure:
QRPreview1.QRPrinter := TQRPrinter(Sender);Return to the form.Right-click the report and choose Send To Back from the popup menu.Double-click the placed report to open the Report Settings dialog. Check the Detail band checkbox, then click OK to create a detail band on the report.
QRDBText [QReport] Place this component on the report抯 detail band.DataSet property: Table1DataField property: CompanyAlignToBand property: True
Toolbar [Win32] No property changes.
Button [Standard] Place this component on the toolbar.Caption property: &PreviewDouble-click the button to open the Code editor window, and enter this for the Button1Click procedure:
QuickRep1.Preview;
QRPreview [QReport] Place the component anywhere on the form below the toolbar.Align property: alClient
3 Press F9 to run the program. Press the Preview button to load the preview. Note the zoom change as you resize the form.
f_QRPreview1.qrprinter:=qrreport1.qrprinter
f_QRPreview1.show;
最后预览后别忘了使f_qrpreview1.qrprinter:=nil;