报表查看器-系统DPI更改带来的缩放问题 [英] Report Viewer - scaling issue with system DPI change

查看:76
本文介绍了报表查看器-系统DPI更改带来的缩放问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Winforms应用程序(在Visual Studio 2010中),该应用程序包含一个Report Viewer控件,该控件可预览和打印A4大小的报告.

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

一个用户的Windows字体大小设置为150%(即系统DPI更改),并且当他运行报表时,在报表查看器"预览和打印的报表中,该字体都会缩小到2/3大小.

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.

包含Report Viewer的窗体的AutoScaleMode属性设置为"Font",尽管如果我更改它似乎不会影响报告.

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.

似乎我需要某种方法在报告本身中指定无论系统dpi设置如何,都应以96dpi呈现它,但是看不到我可以指定的任何地方.我想念什么?

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?

谢谢,大卫

推荐答案

我遇到了同样的问题.WinForms ReportViewer已经了解DPI,并将进行自己的缩放.您只需要告诉系统您的应用程序可以识别DPI,这样系统就不会在以后对其进行扩展.

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>

您还可以使用API​​函数SetProcessDPIAware,但建议针对以下情况: http://msdn.microsoft.com/en-us/library/ms633543.aspx

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

这篇关于报表查看器-系统DPI更改带来的缩放问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆