A newer version of this page is available. Switch to the current version.

Invoke the Report Preview from Code

  • 2 minutes to read

This topic describes how you can display the preview of a specific IReportDataV2 object from a custom Controller code.

The ReportServiceController provides the ReportServiceController.ShowPreview method you can call to invoke the report preview window. The code below demonstrates how to use this method.

using DevExpress.ExpressApp.ReportsV2;
using DevExpress.Persistent.Base;

// Uncomment this line in XPO-based application:
// using DevExpress.Persistent.BaseImpl;

// Uncomment this line in EF-based application:
// using DevExpress.Persistent.BaseImpl.EF;

// ...
IObjectSpace objectSpace = 
IReportDataV2 reportData = 
    CriteriaOperator.Parse("[DisplayName] = 'Contacts Report'"));
string handle = ReportDataProvider.ReportsStorage.GetReportContainerHandle(reportData);
ReportServiceController controller = Frame.GetController<ReportServiceController>();
if (controller != null) {

In the criteria string used in the code above, substitute “Contacts Report” with the actual IReportDataV2.DisplayName value of the report you want to display.


Optionally, you can filter and sort data displayed in report using the criteria and sortProperty parameters of the ShowPreview method.

See Also