且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在没有紧密链接的数据库连接的情况下使用 Crystal Reports?

更新时间:2021-11-24 00:43:02

按照您发布的链接中的说明创建股票对象,并按照他们的指定创建报告 (StockObjectsReport).在这个简化的示例中,我只是将报表查看器 (crystalReportViewer1) 添加到表单 (Form1),然后在 Form_Load 事件中使用以下代码.

Go ahead and create the stock object as described in the link you posted and create the report (StockObjectsReport) as they specify. In this simplified example I simply add a report viewer (crystalReportViewer1) to a form (Form1) and then use the following code in the Form_Load event.

stock s1 = new stock("AWRK", 1200, 28.47);
stock s2 = new stock("CTSO", 800, 128.69);
stock s3 = new stock("LTWR", 1800, 12.95);

ArrayList stockValues = new ArrayList();

stockValues.Add(s1);
stockValues.Add(s2);
stockValues.Add(s3);

ReportDocument StockObjectsReport = new StockObjectsReport();
StockObjectsReport.SetDataSource(stockValues);

crystalReportViewer1.ReportSource = StockObjectsReport;

这应该使用 Windows 窗体中 stock 对象的 3 个值填充您的报告.

This should populate your report with the 3 values from the stock object in a Windows Form.

对不起,我刚刚意识到您的问题是在 VB 中,但我的示例是在 C# 中.你应该得到一般的想法.:)

Sorry, I just realized that your question was in VB, but my example is in C#. You should get the general idea. :)