C# .NET - Report Viewer,Page Setting

Asked By Babitha V on 31-Dec-10 04:30 AM

Iam using the Microsoft.Reporting.Winforms.ReportViewer for report generation. I want to set the default papersize to be tabloid in the page setup, while loading the report viewer.


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using Sms.Core.Business.List;
using Sms.Core.Business.ListingEntity;
using Microsoft.Reporting.WinForms;

namespace Sms.UI.View.ReportForms
{
    public partial class StudentExamMarkReportForm : UserControl
    {
      //private System.Drawing.Printing.PageSettings p = new System.Drawing.Printing.PageSettings();
      private StudentExamMarkListingCriteria Criteria = new StudentExamMarkListingCriteria();

      public StudentExamMarkReportForm(StudentExamMarkListingCriteria Cri)
      {
        this.Criteria = Cri;
        InitializeComponent();
      }

      protected override void OnLoad(EventArgs e)
      {
        this.StudentExamMarkListingObjectBindingSource.DataSource = StudentExamMarkListingList.GetStudentExamMarkListAll(Criteria);
        this.reportviewerStudentExamMark.RefreshReport();
        this.reportviewerStudentExamMark.SetDisplayMode(DisplayMode.PrintLayout);
        //this.reportviewerStudentExamMark.LocalReport.
        //this.reportviewerStudentExamMark.LocalReport.GetDefaultPageSettings();
        //ReportPageSettings s = new ReportPageSettings();
        //s.PaperSize.pa = System.Drawing.Printing.PaperKind.Tabloid;
        //p.PrinterSettings.PaperSize
        //s.PaperSize.PaperName = System.Drawing.Printing.PaperKind;
        //this.reportviewerStudentExamMark.LocalReport.GetDefaultPageSettings().PaperSize.Kind
        //this.reportviewerStudentExamMark.LocalReport.GetDefaultPageSettings().PaperSize.PaperName = Convert.ToString(System.Drawing.Printing.PaperKind.Tabloid);
      }
    }
}

Reena Jain replied to Babitha V on 31-Dec-10 04:51 AM
hi,

The default paper size is set  in the .rdlc file. Here's how you can set the default to Legal:

Open the .rdlc file using Report Designer. Then from the menu choose Report > Report Properties. In Report Properties dialog switch to Layout tab. Set Page Width to 612pt and Page Height to 1008pt. Save the report and run the application. Now when you open the Page Setup dialog in the ReportViewer control the paper size defaults to Legal.

here is one good link for your help

http://msdn.microsoft.com/en-us/library/system.drawing.printing.pagesettings.papersize.aspx

Hope this will help you
Babitha V replied to Reena Jain on 31-Dec-10 05:55 AM
Hi Reena,
        Thanks for ur suggession. Its working correctly.

welcome:)

Reena Jain replied to Babitha V on 31-Dec-10 07:32 AM
end of post