首页 > 解决方案 > 如何使用 Active Reports 13 rdlx 报告动态设置子报告的数据源

问题描述

我有一个使用 rdlx 格式定义的 Active Reports 13 报告。该报告还包含一些子报告。

在报表设计器中定义时,数据源设置为一些测试数据,但是,当报表嵌入 WPF 应用程序时,我们希望实用地更新数据库的位置。

我们已经能够更新主报表的数据源,但是(对我们来说!)不清楚如何更新子报表的数据源。

string report = _reportPath;
// checked the report file exists ...
if (File.Exists(report))
{
    // create and setup the data source
    // create an empty page report
    GrapeCity.ActiveReports.PageReport def = new GrapeCity.ActiveReports.PageReport();

    //load the report layout
    def.Load(new System.IO.FileInfo(report));

    //setup the dataset
    GrapeCity.ActiveReports.PageReportModel.DataSource myDataSource = def.Report.DataSources[0];

    def.Report.DataSources[0].ConnectionProperties.DataProvider = "OLEDB";

    def.Report.DataSources[0].ConnectionProperties.ConnectString = @"RunData.mdb;provider=Microsoft.Jet.OLEDB.4.0;";


    // loop through subreports and set the location of the run data database
    // ????

    reportViewer.LoadDocument(def.Document);
}

有没有人指出我们应该如何在“????”处编写代码 上面还更新子报告?

标签: datasourcesubreportactivereports

解决方案


这是在报告文档LocateDataSource上的事件中完成的

此外,请参阅此示例以了解如何使用 LocateDataSource:DataSet DataSource您可以通过在此处下载 ActiveReports 13 试用版来访问示例应用程序。

最好的,

葡萄城支持团队


推荐阅读