In our projects, we always end up creating a ReportViewer
form that purpose is to display a XtraReport
(or PrintingSystem
).
The viewer consist of a normal XtraForm on which we drop a PrintRibbonController. That will automatically create the ribbon bar and the print control.
Then we use a method that bind the report to the viewer:
public partial class ReportViewer : DevExpress.XtraEditors.XtraForm
{
public ReportViewer()
{
InitializeComponent();
}
// Used when displaying a single report
public void SetReport(XtraReport report)
{
this.printControl.PrintingSystem = report.PrintingSystem;
report.CreateDocument();
this.printControl.UpdatePageView();
}
// Used when displaying merged reports
public void SetReport(PrintingSystem system)
{
this.printControl.PrintingSystem = system;
this.printControl.UpdatePageView();
}
}
So displaying a report goes like this:
ReportViewer viewer = new ReportViewer();
viewer.SetReport(new EmployeeReport());
viewer.Show();
This approach of creating your own viewer can help you:
- Manages security by user (for example: a normal user can't change the watermark),
- Changes the ribbon by removing or adding button to fit your requirements.