Crystal Report View page numbers
I am using the Crystal Report Viewer in an ASP.NET application. On the viewer it displays the page numbers along the lines of '1 / 1+' where the开发者_JAVA技巧 1+ is dynamically calculated. I would like it to display the correct total number of pages from the start rather than 1+. Is there a way to do this?
I think a number of the examples online recommend that you navigate to the last page and then back to the first, but I don't think this is a good way of handling it. I have yet to have the need to do this for any of my projects so I haven't had to try to find a work around yet.
Edit-
Ok, after looking at this just now I realized that if you add the "Page N of M" special field it does the dynamic calculation at runtime. In my testing it will do the dynamic calculation even if you choose to suppress the field by checking the suppress box in the field properties. Granted the dynamic calculation might be slower for larger reports, this is probably just as good as programmatically navigating to the last page and back to the first. Hope this helps.
Crystal Report's Page engine renders sections the first page as quickly as possible to give the perception of performance. You may have noticed field values rendering quickly, with place holders (spaces) for subreports and other resource-intensive objects. As the Rendering engine finishes processing these objects, the place holders are replace with values.
The page numbering situation is similar. The navigation control will initially read '1+', but will increment as the Page engine renders additional pages. When the whole report is rendered, the navigation control and the Page N of M field will display the total page count.
If you insist on altering the user-experience, you may be able to use the Viewer's BeforeRender or BeforeRenderContent event to set HasPageNavigationButtons=False and AfterRender or AfterRenderContent event to HasPageNavigationButtons=True.
I'm not certain that you will be able to do something similar with the Page-N-of-M field.
You have a property called TotalPageCount. If you put that in your report will show the page numbers correctly. For example, I have a formula field like ToText(PageNumber,0) + "/" + ToText(TotalPageCount,0) to show current page from total pages.
精彩评论