我正在开发一个WPF应用程序,我使用包含一个图表的ReportViewer,但我需要在报告中显示另一个图表。我创建了一个子报表,并在我的主报表中调用它。但是,如果我在子报表中插入图表不起作用!
The Subreport1 could not be found at the specified location. Please verify that the subreport has been published and that the name is correct.
如果我使用表格或文本框,它可以工作但不是图表。
这是我的代码Behind:
private void showReport(object sender, RoutedEventArgs e)
{
RVInfoGrafico.Reset();
RVInfoGrafico.LocalReport.DataSources.Clear();
RVInfoGrafico.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(MSubreportProcessingEventHandler);
DataTable dt = GetData2();
ReportDataSource rds = new ReportDataSource("DataSet1", dt);
RVInfoGrafico.LocalReport.DataSources.Add(rds);
RVInfoGrafico.LocalReport.ReportEmbeddedResource = "Project.Info.rdlc";
RVInfoGrafico.ProcessingMode = ProcessingMode.Local;
RVInfoGrafico.RefreshReport();
}
void MSubreportProcessingEventHandler(object sender, SubreportProcessingEventArgs e)
{
DataTable dt9 = GetData4();
e.DataSources.Add(new ReportDataSource("DataSet1",dt9));
}
答案 0 :(得分:0)
错误表明它无法找到Subreport1。也许尝试使用LoadSubreportDefinition直接提供它(" Subreport1",xxx)?
这样的事情:
var asm = Assembly.GetExecutingAssembly();
var stream = asm.GetManifestResourceStream("RVInfoGrafico.Reports.Subreport.rdlc"); // Change to your path or get a stream of it some other way
RVInfoGrafico.LocalReport.LoadSubreportDefinition("Subreport1", stream);
仅供参考 - 在我完成此项目的项目中,.rdlc文件' VisualStudio中的Build Action设置为" Embedded Resource"。