Exemplo n.º 1
0
        // This is where the appearance of most of the toolbar items are set
        private void ReportViewer1_StatusChanged(object sender, EventArgs e)
        {
            ReportViewerStatus status = ReportViewer1.CurrentStatus;

            this.SuspendLayout();

            // Set page navigation items
            if (status.CanNavigatePages)
            {
                ButtonFirstPage.Enabled = (ReportViewer1.CurrentPage > 1);
                ButtonPrevPage.Enabled  = (ReportViewer1.CurrentPage > 1);

                TextBoxPageNum.Enabled = true;
                TextBoxPageNum.Text    = ReportViewer1.CurrentPage.ToString();
                PageCountMode mode;
                int           total = ReportViewer1.GetTotalPages(out mode);
                LabelTotalPages.Text = String.Format("of {0}{1}", total, (mode == PageCountMode.Estimate ? "?" : String.Empty));

                ButtonNextPage.Enabled = (ReportViewer1.CurrentPage < total);
                ButtonLastPage.Enabled = (ReportViewer1.CurrentPage < total);
            }
            else
            {
                ButtonFirstPage.Enabled = false;
                ButtonPrevPage.Enabled  = false;
                TextBoxPageNum.Enabled  = false;
                TextBoxPageNum.Text     = String.Empty;
                ButtonNextPage.Enabled  = false;
                ButtonLastPage.Enabled  = false;
            }

            // Set Back, Stop, and Refresh buttons
            ButtonBack.Enabled    = status.CanNavigateBack;
            ButtonStop.Enabled    = status.InCancelableOperation;
            ButtonRefresh.Enabled = status.CanRefreshData;

            // Set Print, Print Preview, Page Setup, and Export buttons
            ButtonPrint.Enabled    = status.CanPrint;
            ButtonPreview.Enabled  = status.CanChangeDisplayModes;
            ButtonPreview.Checked  = ReportViewer1.DisplayMode == DisplayMode.PrintLayout;
            ButtonSetup.Enabled    = status.CanNavigatePages;
            DropDownExport.Enabled = status.CanExport;

            // Set zoom and search items
            DropDownZoom.Enabled = status.CanChangeZoom;
            TextBoxFind.Enabled  = status.CanSearch;
            ButtonFind.Enabled   = (status.CanSearch && TextBoxFind.Text.Length > 0) ? true : false;
            ButtonNext.Enabled   = status.CanContinueSearch;

            this.ResumeLayout();
        }
Exemplo n.º 2
0
        private void ButtonLastPage_Click(object sender, EventArgs e)
        {
            PageCountMode mode;
            int           total = ReportViewer1.GetTotalPages(out mode);

            if (mode == PageCountMode.Estimate)
            {
                ReportViewer1.CurrentPage = ReportViewer.MaximumPageCount;
            }
            else
            {
                ReportViewer1.CurrentPage = total;
            }
        }