【发布时间】:2014-05-09 04:31:57
【问题描述】:
我创建了一个水晶报表,然后在创建它之后,我创建了一个 winform,我在其中导入了水晶报表库(以代码显示)并使用报表查看器查看报表,但我无法查看报告,代码,我是 Crytal Reports 的新手,我所做的代码是:
代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
namespace InventorySoftware
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.reportViewer1.RefreshReport();
}
private void button1_Click(object sender, EventArgs e)
{
//string ReportSources = "";
ReportDocument cryRpt = new ReportDocument();
cryRpt.Load("C:\\Users\\Ahsan\\Desktop\\PROJECT INVENTORY SOFTWARE\\InventorySoftware\\InventorySoftware\\CrystalReport1.rpt");
reportViewer1.ReportSource = cryRpt;
reportViewer1.Refresh();
}
}
}
reportViewer1.ReportSource = cryRpt; 出现错误,错误是
Error 1 'Microsoft.Reporting.WinForms.ReportViewer' does not contain a definition for 'ReportSource' and no extension method 'ReportSource' accepting a first argument of type 'Microsoft.Reporting.WinForms.ReportViewer' could be found (are you missing a using directive or an assembly reference?) C:\Users\Ahsan\Desktop\PROJECT INVENTORY SOFTWARE\InventorySoftware\InventorySoftware\Form1.cs 34 27 InventorySoftware
【问题讨论】:
标签: c# winforms visual-studio-2008 crystal-reports