C# 如何在ReportViewer C的子报表中生成图表#

C# 如何在ReportViewer C的子报表中生成图表#,c#,wpf,charts,reportviewer,C#,Wpf,Charts,Reportviewer,我目前正在开发一个WPF应用程序,我使用的ReportViewer包含一个图表,但我需要在报告中显示另一个图表。我创建一个子报表并在主报表中调用它。但如果我在子报表中插入图表,则无法正常工作! 在指定位置找不到子报表1。请验证子报表是否已发布以及名称是否正确。 如果我使用表格或文本框,它会工作,但如果使用图表,则不会工作。 这是我的代码隐藏: private void showReport(object sender, RoutedEventArgs e) {

我目前正在开发一个WPF应用程序,我使用的ReportViewer包含一个图表,但我需要在报告中显示另一个图表。我创建一个子报表并在主报表中调用它。但如果我在子报表中插入图表,则无法正常工作! 在指定位置找不到子报表1。请验证子报表是否已发布以及名称是否正确。 如果我使用表格或文本框,它会工作,但如果使用图表,则不会工作。 这是我的代码隐藏:

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));
        }

错误表明找不到子报表1。也许可以尝试直接使用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);
仅供参考-在我在中完成的一个项目中,VisualStudio中.rdlc文件的构建操作被设置为“嵌入式资源”