Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何浏览Crystal Reports 2008中的子报表集合?_C#_Crystal Reports - Fatal编程技术网

C# 如何浏览Crystal Reports 2008中的子报表集合?

C# 如何浏览Crystal Reports 2008中的子报表集合?,c#,crystal-reports,C#,Crystal Reports,我的报告中有很多子报告 如何浏览主报表中的子报表集合?我需要它来更改每个子报表的数据源 TIA根据CodeByMoonlight评论编辑-我还没有测试过这个,但它应该比我的原创版本好得多 ReportDocument reportDocument = new ReportDocument(); reportDocument.Load(...); foreach (ReportDocument subreportDocument in reportDocument.Subreports) {

我的报告中有很多子报告

如何浏览主报表中的子报表集合?我需要它来更改每个子报表的数据源


TIA

根据CodeByMoonlight评论编辑-我还没有测试过这个,但它应该比我的原创版本好得多

ReportDocument reportDocument = new ReportDocument();
reportDocument.Load(...);
foreach (ReportDocument subreportDocument in reportDocument.Subreports) {   
  // do something here
} 

稍微有些过火-ReportDocument本身有一个SubReports属性,因此您不需要枚举每个报表对象并检查它是否是一个子报表。@moonlight-thanx-看起来好多了。我的原始代码是我多年来一直在使用的-我想知道Subreports属性是否相当新,或者我只是第一次错过了它…好得多:)我想它已经存在了一段时间,但我没有太多的电话使用它。