How to Get Total Page Count for a Report Using CrystalReportViewer?

给你一囗甜甜゛ 提交于 2020-01-06 06:50:13

问题


I am using Crystal Report 2008 with C#, have a WinForm and want to show Page N of M to user in a Label.
How can I impelemnt that?
I searched and couldn't find any straightforward answer.
NOTICE: I used a CrystalReportViewer1 and CRGeneral.rpt


回答1:


this way works well But i think I can Find better solution:

        viewer.ShowLastPage();
        string TotalPage = viewer.GetCurrentPageNumber().ToString();
        viewer.ShowFirstPage(); 
        pageNo.Text = viewer.GetCurrentPageNumber() + " of " + TotalPage;


Any Better Answer?




回答2:


Yes there is a better answer

viewer.pageView = (PageView)viewer.Controls[0];

var pagecount = viewer.pageView.GetLastPageNumber();

Source Take Control of Crystal Report Viewer



来源:https://stackoverflow.com/questions/1306985/how-to-get-total-page-count-for-a-report-using-crystalreportviewer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!