C# – Report Viewer – scaling issue with system DPI change

creportviewerwinforms

I have a Winforms application (in Visual Studio 2010) that contains a Report Viewer control that previews and prints an A4 size report.

One user has his Windows font size set to 150% (i.e. a system DPI change) and when he runs the report, it is shrunk to 2/3 size in both the Report Viewer preview and the printed report.

The AutoScaleMode property of the form containing the Report Viewer is set to "Font", although it doesn't seem to affect the report if I change this.

This isn't a font (missing/scaling) issue as I have an example program to demonstrate the problem that contains nothing but a rectangle that takes up the whole page.

It seems I need some way to specify in the report itself that it should be rendered at 96dpi regardless of the system dpi setting, but can't see anywhere that I can specify this. What am I missing?

Thanks,
David

Best Answer

I ran into the same problem. WinForms ReportViewer is already DPI aware and will do its own scaling. You just have to tell the system that your application is DPI aware so that the system doesn't try to scale it after.

Add a manifest to your application if you haven't already, then inside the tag, add the following:

  <asmv3:application  xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" >
    <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
      <dpiAware>true</dpiAware>
    </asmv3:windowsSettings>
  </asmv3:application>

You can also use an API function SetProcessDPIAware, but it is recommended against: http://msdn.microsoft.com/en-us/library/ms633543.aspx

Related Topic