C# – Set ReportViewer to Legal Page Size at load using c#

crdlcreportviewer

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.

Best Answer

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.

Related Topic