Hide a report item from print / export of an rdlc report

一笑奈何 提交于 2019-12-24 04:25:07

问题


I have an RDLC with multiple tables and for each table, I have a toggle TextBox Item that hides the corresponding table from the report. It works perfectly, however, I don't want these text boxes to be visible in the printed/exported reports. They are really meant for disabling content in the report and not as content themselves. Is there a way to hide those toggle boxes from only Print Layout and exported versions of the report?

I looked at all of the properties of the report textbox and at the available expressions that I can use to toggle visibility, but I didn't find anything that I can use to hide the item. There is a DataElementOutput property that seems to be what I want, but I believe that it is only useful for XML.


回答1:


Late, but there are one solution. You can add a parameter to the report for handle control visibility and in the Print event, change the parameter value and then refresh the report (ReportViewer1.RefreshReport())




回答2:


This can be achieved using a simple visibility toggle. You can use the RenderFormat.IsInteractive variable to determine whether a report is shown in report viewer or is being exported. An MSDN article explains this about this global variable,

Furthermore, a Boolean flag (=Globals!RenderFormat.IsInteractive) determines whether a rendering extension is an interactive renderer, i.e. not an export format. Preview (GDI/Winforms) and HTML viewing are considered interactive renderers.

Set the visibility of the text box you want to hide in the export to the following expression

=NOT(Globals!RenderFormat.IsInteractive)

Refer to the following image (courtesy of blog.hoegaerden.be) to know the values assigned to RenderFormat.IsInteractive




回答3:


You can do some hacks to try to accomplish that like: - setting the text and border on your TextBox to be white so they are not vislble but still clickable - make report bigger than print size (paper size) and move your textboxes out of the print area (they will be printed/exported but not on the same page like your tables) - put your textboxes on top and design them to look like tabs which enable different views (I know, I know, this is not what you asked for :-) )

But the best way to solve this is to split your report in to several reports - for each table one report.

hope this helps!

cheers,

Pero



来源:https://stackoverflow.com/questions/1069500/hide-a-report-item-from-print-export-of-an-rdlc-report

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!