WinReportServiceController.CustomShowPreview Event

Occurs before showing the report's Preview dialog.

Namespace: DevExpress.ExpressApp.Reports.Win

Assembly: DevExpress.ExpressApp.Reports.Win.v18.1.dll

Declaration

public event EventHandler<CustomShowPreviewEventArgs> CustomShowPreview
Public Event CustomShowPreview As EventHandler(Of CustomShowPreviewEventArgs)

The event handler receives an argument of the DevExpress.ExpressApp.Reports.Win.CustomShowPreviewEventArgs type.

Handle the CustomShowPreview event to implement a custom logic to be executed before, or instead of, displaying the Preview dialog. You can access the report via the handler's Report parameter. Additionally, you can access the PrintTool object, to modify the printing options. Set the handler's Handled parameter to suppress the default Report Wizard.

using DevExpress.XtraReports.UI;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Reports.Win;
// ...
public class ConfigurePrintingSystemViewController : ViewController {
    private WinReportServiceController reportService;
    protected override void OnActivated() {
        base.OnActivated();
        reportService = Frame.GetController<WinReportServiceController>();
        if (reportService != null) {
            reportService.CustomShowPreview += reportService_CustomShowPreview;
        }
    }
    private void reportService_CustomShowPreview(
        object sender, CustomShowPreviewEventArgs e) {
        e.Report.CreateDocument();
        e.PrintTool.PrintingSystem.ExportOptions.PrintPreview.ShowOptionsBeforeExport = false;
        e.Report.ShowPreviewDialog();
        e.Handled = true;
    }
    protected override void OnDeactivating() {
        if (reportService != null)
            reportService.CustomShowPreview -= reportService_CustomShowPreview;
    }
}
Note

The ShowPreviewDialog method is an extension method implemented in the DevExpress.XtraPrinting.v18.1.dll assembly. A reference to this assembly is required to compile the code above.

Refer to the How to: Customize Export Options of the Printing System topic, to see another example of using the CustomShowPreview event.

See Also