views:

22

answers:

2

Using WinForms.ReportViewer I'd like to get a hold of the number of pages that are rendered.

I need to generate a contents page for a collection of reports and to do this I need to know how many A4 pages are rendered for each report so that I can subsequently generate the contents page. The reports are able to be edited by the end user and replaced so that the next time it's run the number of pages could be different and so the contents would need to be re-generated.

I've managed to get the reports to load at runtime based on the files provided by the end user, but getting hold of the number of pages the report renders is proving quite difficult. I know I can get this information in the header of the report, but know of no way to get that information back out, programatically.

+3  A: 

Try using:

int pageCount = Viewer1.Document.Pages.count;
Michael Eakins
A: 

I actually just needed to do an Application.DoEvents() call after calling the display method, before checking the page count. It obviously renders the report in a separate thread...

Matt Fellows