views:

784

answers:

2

I wrote a c# program that displays rdlc reports locally using the .net reportviewer. I can't figure out how to set page size to "Legal" instead of "Letter" when the reportviewer loads.

For example: This is how I refer to the reportviewer at load time to change the report path.

            reportViewer1.LocalReport.ReportPath = strRptResource.ToString();

Can I change the page setup to "Legal" using a similar syntax?

FYI, the margins and page size are already set properly in the rdlc file.

+1  A: 

This setting is held in the RLDC file (the report definition XML file). You are able to set this when editing a Report, under Report Properties. You actually need to specify the Width and Height manually.

In order to do this during load time, you would need to load the RDLC file into memory, alter the value for Width and Height, then load the report with the altered report definition.

Jon
A: 

You page width and height must match the one the one you're aiming for . Be very cautious to be the exact size because if you don't, it might have problems with determining the paper type even if it's really close.

Also, if you're using centimeters as units in your applications, define the page witdh and height to inches instead. I had that problem more than once before.

If you want to changed it dinamically, then you can create a copy of the report, change the value you need (it's a xml base file so you can open it to see for yourself)

Check this for more info.

David Brunelle