Question
“How can I hide the Print button of the Report Preview?”
Solution
Here are two options:
1. Implement Report.OnPreviewFormCreate event:
1 2 3 4 5 6 7 |
uses ppPrvDlg; procedure TForm1.ppReport1PreviewFormCreate(Sender: TObject); begin TppPrintPreview(ppReport1.PreviewForm).PrintButton.Visible := False; end; |
2. Implement a custom TppPreviewPlugin:
This solution is best for the case in which you need to hide the Print button for all (or many) reports:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
unit MyPreviewPlugin; interface uses Classes, ppTypes, ppPreview; type TMyPreviewPlugin = class(TppPreview) private protected public constructor Create(aOwner: TComponent); override; end; implementation { TMyPreviewPlugin } constructor TMyPreviewPlugin.Create(aOwner: TComponent); begin inherited; PrintButton.Visible := False; end; initialization TppPreviewPlugIn.Register(TMyPreviewPlugin); finalization TppPreviewPlugIn.UnRegister(TMyPreviewPlugin); end; |