6

Here is my code, working but i am getting blank printing ? I want set Top margin as 0 when i dont have Logo as Image.

System.Drawing.Printing.PageSettings pg = new System.Drawing.Printing.PageSettings();
pg.Margins.Top = 0;
pg.Margins.Bottom = 0;
pg.Margins.Left = 100;
pg.Margins.Right = 50;
System.Drawing.Printing.PaperSize size = new PaperSize();
size.RawKind = (int)PaperKind.A4Extra;
pg.PaperSize = size;
reportViewer1.SetPageSettings(pg);
2
  • 5
    You can do this in the report itself. Open the report in the report designer (Visual Studio) top menu bar "Report" -> "Report Properties" I believe. Do you do your "reportViewer1.SetPageSettings(pg)" after you load the report?
    – Shelby115
    Commented Oct 2, 2013 at 3:35
  • yes i have tried this before and after loading report same problem visualization is same as coding but printing is empty. Commented Oct 2, 2013 at 18:41

1 Answer 1

9

you can do by the Page Settings or something like this..

var setup = frmReport.reportViewer1.GetPageSettings();           
setup.Margins = new System.Drawing.Printing.Margins(1, 1, 1, 1);
frmReport.reportViewer1.SetPageSettings(setup);
2
  • The following does not work. I am using Visual Studio 2015. The error says "ReportPageSetting.Margins can not be assigned to -- it is a read-only property"
    – Shahbaaz
    Commented Dec 6, 2017 at 13:41
  • 2
    I've tried in vs2010 and 2015 without problem.. i gotta se if you're getting the correct property. link
    – Pacheco
    Commented Apr 18, 2018 at 11:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.