[英]How to generate Charts in SubReport in ReportViewer C#
我目前正在開發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.
如果我使用表格或文本框,則可以使用,但如果使用圖表則不能。 這是我的代碼背后:
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));
}
錯誤指出找不到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);
僅供參考-在我完成的項目中,Visual Studio中的.rdlc文件的“生成操作”被設置為“嵌入式資源”。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.