微软报告:设置代码报表参数 [英] Microsoft Reporting: Setting subreport parameters in code

查看:240
本文介绍了微软报告:设置代码报表参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置子报表的参数?我已经成功地迷上自己到SubreportProcessing事件,我可以通过e.ReportPath找到正确的分报告中,我可以通过添加e.DataSources.Add数据源。但是我觉得没有添加报表参数的方法?

How can I set a parameter of a sub-report? I have successfully hooked myself up to the SubreportProcessing event, I can find the correct sub-report through e.ReportPath, and I can add datasources through e.DataSources.Add. But I find no way of adding report parameters??

我发现人们建议将它们添加到主报告,但我真的不希望这样做,由于主报告不应该被连接到副报告可言,除了它是包裹子报告

I have found people suggesting to add them to the master report, but I don't really want to do that, since the master report shouldn't have to be connected to the sub-report at all, other than that it is wrapping the sub-report.

我使用一个报告作为主模板,报表,页码等印刷的名称和报表将是报告本身。如果我只能找到一种方法来设置分报告的这些报表参数我会好去...

I am using one report as a master template, printing name of the report, page numbers etc. And the subreport is going to be the report itself. And if I could only find a way to set those report parameters of the sub-report I would be good to go...

澄清: 创建/定义的参数不是问题。的问题是要设定它们的值。我认为自然的事情是做在SubreportProcessing事件。而SubreportProcessingEventArgs做其实有一个参数属性。但它仅仅是阅读!那么,如何使用?如何设置自己的价值?

Clarification: Creating/Defining the parameters is not the problem. The problem is to set their values. I thought the natural thing to do was to do it in the SubreportProcessing event. And the SubreportProcessingEventArgs do in fact have a Parameters property. But it is read only! So how do you use that? How can I set their value?

推荐答案

寻找和期待之后,我得出的结论是,设置子报告的参数,在代码,是不可能的。除非你做一些花哨的类似开始编辑报告定义的XML加载它,或者类似的东西了。

After looking and looking, I have come to the conclusion that setting the parameters of a sub-report, in code, is not possible. Unless you do something fancy like start editing the xml of the report definition before you load it or something like that.

(但是,如果别人要知道,我错了,请做答案,因为我还是很好奇,想知道!)

(But if someone else should know that I am wrong, please do answer, cause I am still very curious to know!)

这篇关于微软报告:设置代码报表参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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