poo*_*han 5 c# reporting rdlc subreport winforms
我想使用相同的子报表来显示不同的数据。
我试图创建类列表(对于该子报告)并在子报告处理方法中将每个项目分配给一个子报告,是的,我可以做到,但每个子报告仅显示以下数据显示第一个子报告。
但是我在代码中进行了调试,我发现实际上我为每个子报告发送了不同的数据源,但它们都显示相同的内容,
private static int index = 0;
public void LocalReport_SubreportProcessing(object sender, Microsoft.Reporting.WinForms.SubreportProcessingEventArgs e)
{
var mainSource =
(((Microsoft.Reporting.WinForms.LocalReport) sender).DataSources["DataSet"]).Value as BindingSource;
if (mainSource == null) return;
switch (e.ReportPath)
{
case "FeedbackBar":
{
var List = mainSource.DataSource as List<Classes.Feedback>;
if (List != null)
{
var lst = List[index++].List as B[];
e.DataSources.Add(new ReportDataSource("DataSet", lst));
}
}
break;
}
}
Run Code Online (Sandbox Code Playgroud)