我尝试在.Net C #Windows表单中实现Crystal报表。当Run crystal报表时,通过项目参数提示框询问参数。所有参数都是在C#中动态设置的。
代码:
ReportDocument rptDoc = new ReportDocument();
rptDoc.SetDataSource(dt1);
rptDoc.Load("ChequePrint.rpt");
rptDoc.SetParameterValue(0, trnKy);
// Set Data Base Connection
rptDoc = this.SetCrystalConnection(rptDoc);
// Pass Report Document to Crystal Viewer form
frmCrystalReportViewer crystalViewFrm = new frmCrystalReportViewer();
crystalViewFrm.loadReport(rptDoc);
crystalViewFrm.Show();
Crystal Viewver表格:
try
{
rptDoc.Refresh();
crystalReportViewer1.ReportSource = rptDoc;
success = true;
}
catch (Exception ex)
{
success = false;
}