Rado
Rado

Reputation: 8963

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

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.

Upvotes: 2

Views: 3449

Answers (3)

Kolappan N
Kolappan N

Reputation: 4011

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 RenderFormat.IsInteractive

Upvotes: 1

Hugo
Hugo

Reputation: 36

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())

Upvotes: 1

Perica Zivkovic
Perica Zivkovic

Reputation: 2630

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

Upvotes: 0

Related Questions