c#里代码如下,没有编译错误,运行也正常:
private void listreport_Load(object sender, EventArgs e)
{
reportName = mainForm.m_strDataFilePath + "listReport.rdlx";
GrapeCity.ActiveReports.PageReport report = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(reportName));
report.Document.LocateDataSource += new GrapeCity.ActiveReports.LocateDataSourceEventHandler(Document_LocateDataSource);
//显示报表
viewer1.LoadDocument(report.Document);
}
void Document_LocateDataSource(object sender, GrapeCity.ActiveReports.LocateDataSourceEventArgs args)
{
if (args.DataSet.Query.DataSourceName == "DataSource1")
{
if (args.DataSet.Name == "DataSet1")
{
args.Data = GetData();
}
}
}
private DataTable GetData()
{
DataTable dt = new DataTable();
dt.Columns.Add("Col1");
dt.Columns.Add("Col2");
dt.Columns.Add("Col3");
dt.Columns.Add("Col4");
dt.Columns.Add("Col5");
dt.Rows.Add(1, 1, 10, 11, 12);
dt.Rows.Add(2, 1, 10, 11, 12);
dt.Rows.Add(3, 1, 10, 11, 12);
dt.Rows.Add(4, 1, 10, 11, 12);
dt.Rows.Add(5, 1, 10, 11, 12);
dt.Rows.Add(6, 1, 10, 11, 12);
return dt;
}
listReport.rdlx报表内容如下:
运行程序后,显示结果如下:
动态赋值的数据没有显示出来,是哪里的问题啊?
|