Symptom
- A Crystal Report is sent to the viewer.
- What API should be used to clear out the first report, before sending the next report to the viewer?
Environment
- SAP Crystal Reports, developer version for Microsoft Visual Studio
- Microsoft Visual Studio (2010 / 2012)
Cause
- The WPF viewer does not have any exposed APIs that would clear the viewer.
Resolution
- Work-Around:
- Create a blank.rpt report with nothing in it, no database connection.
- Save the report with the option "Saved data" enabled.
- Use the following code:
private void button1_Click(object sender, RoutedEventArgs e)
{
// Button1 to view the first report
CrystalDecisions.CrystalReports.Engine.ReportDocument doc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
doc.Load(@"c:\reports\formulas1.rpt");
crystalReportsViewer2.ViewerCore.ReportSource = doc;
crystalReportsViewer2.ViewerCore.Visibility = Visibility.Visible;
}
private void button2_Click(object sender, RoutedEventArgs e)
{
// Button2 to close and display the blank report, thus simulating an empty viewer
CrystalDecisions.CrystalReports.Engine.ReportDocument doc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
doc.ReportClientDocument.Close();
doc.Load("C:\\reports\\blank1.rpt");
crystalReportsViewer2.ViewerCore.ReportSource = doc;
}
Keywords
CRVS CR4VS 2012 2010 NET VS C# empty remove blank out , KBA , BI-DEV-NET-SDK , .NET SDK / COM SDK , How To
Product
SAP Crystal Reports, developer version for Microsoft Visual Studio