在运行时添加子报表 [英] Add SubReport At Runtime

查看:63
本文介绍了在运行时添加子报表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我创建一个报告并将其命名为MainReport.rpt
我想将该报告用于所有应用程序报告,只有报告正文可以更改(某些页眉和页脚),我在主报告中放置了一个子报告对象,当我使用MainReport.subreports时需要在运行时加载报告[0] .OpenSubreport(reportName)我收到错误消息,
请帮助我如何在子报表对象中加载所需的报表

Hi ,
I am create a report and named it MainReport.rpt
i want to user this report for all application reports ,only the report body can change (some Header and Footer) , i put a subreport object int the main report and i need to load the report at runtime when i am use the MainReport.subreports[0].OpenSubreport(reportName) i get a error ,
please help me how i can load the desired report in the subreport object

推荐答案

您可以尝试以下操作

在加载主报表时创建事件处理程序
You can try this

create eventhandler at the time of main report loading
ReportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(LocalReport_SubreportProcessing);


然后


then

void LocalReport_SubreportProcessing(object sender, SubreportProcessingEventArgs e)
    {
        String param= e.Parameters[0].Values[0];

        ReportDataSource datasource = new ReportDataSource("subrptdatasourcename",subrptdatasource);
        e.DataSources.Add(datasource);
    }


这篇关于在运行时添加子报表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆