Using own preview window
Using the FastReport.Utils.Config.PreviewSettings
global class (see the "Configuring the FastReport environment" section), you may tune up the standard preview window.
If you don't want to use the standard preview window for some reason, you may create your own. To do this, use the PreviewControl control (WpfPreviewControl for FastReport WPF, AvaloniaPreviewControl for FastReport Avalonia) that can be added on your form. To show a report in this control, connect it to the Report object by the following code:
report1.Preview = previewControl1; // WinForms/Mono
report1.WpfPreview = previewControl1; // WPF
report1.AvaloniaPreview = previewControl1; // Avalonia
To prepare a report and show it in the PreviewControl, use the Show
method of the Report object:
report1.Show();
your_form.ShowDialog();
or the following code:
if (report1.Prepare())
{
report1.ShowPrepared();
your_form.ShowDialog();
}
In these examples, the your_form
is your form that contains the PreviewControl.
Using the methods of PreviewControl component, you can handle it from your code. You may even turn off the standard toolbar and/or statusbar, using the ToolbarVisible
, StatusbarVisible
properties.
This is demonstrated in the \Demos\C#\CustomPreview example project (in FastReport WPF, the demo is located here: \Demos\WPF\CustomPreview; in FastReport Avalonia, the demo is located here: \Demos\Avalonia\CustomPreview).