Skip to Content
0
Former Member
Jan 13, 2011 at 03:59 AM

WPF CrystalReportsViewer Loaded event - Load Report Failed

123 Views

Hi

I am using Crystal for VS2010 (ver 13) WPF.

I need to know how to generate an instance of a Crystal report without the CrystalReportsViewer having been loaded.

It seems I have to wait for the CrystalReportsViewer Loaded event to fire before I can generate my report. This isn't a problem if I generate a single report that appears in the viewer inside a tab, but if I want to generate multiple reports, then they are quickly opening in multiple tabs each with it's own CystalReportsViewer. But the Loaded event only fires for the CrystalReportsViewer that is visible in the last active tab.

If I try generate the report prior to the Loaded event firing, I get exceptions like "Load Report Failed" or something to do with the report engine not being initialised.

eg. If I have a CrystalReportsViewer inside a UserControl, I can't generate the reportDocument on the UserControl's DataContextChanged event, but I can generate it on the CrystalReportsViewer Loaded event.

CrystalDecisions.CrystalReports.Engine.ReportClass report = myReportAssembler.GetReport(myInputData);

this eventually calls myReportDocument.SetDataSource(myDataSet) which fails as the report engine apparently hasn't been initialised yet.

Edited by: cgrapentin on Jan 13, 2011 5:04 AM