在运行时在rdlc报告中显示/隐藏列
问题描述:
大家好,
我想创建一个带有动态列的rdlc报告.我的意思是我想让用户选择他想在报告中查看的列.我的数据也在数据表中.
我该怎么办?
Hi all,
I want to create a rdlc report with dynamic columns.I mean i want to let user to select columns that he want to view in his report.also my data is in a datatable.
how can i do that?
Is there an easier way if i use Crystal Report?
答
其中一种方法如下:
a)添加数据集并设计具有所有必需列的RDLC报告
b)每个动态列添加一个报表布尔参数
c)在rdlc设计模式下右键单击列,然后选择列可见性"
-选择基于表达式显示或隐藏",然后选择报告参数
d)在后面的代码中,使用ReportViewer.LocaReport.SetParameters方法设置布尔参数值,"true"隐藏,"false"显示.
看看是否有帮助.
One of the approaches is as follows:
a) Add the dataset and design the RDLC report with all required columns
b) Add one report boolean parameter per dynamic column
c) Right click on column in rdlc design mode and select Column Visibility
- Select "Show or Hide based on an expression" and select the report parameter
d) In code behind, use ReportViewer.LocaReport.SetParameters method to set the boolean parameter values, "true" to hide and "false" to show.
See if this helps.