简体   繁体   English

WinForms 应用程序中某些用户的项目在屏幕外裁剪

[英]Items clipping off-screen for some users in WinForms application

I am experiencing a very strange issue, and unfortunately it is not very reproducible so I don't have a lot to go on.我遇到了一个非常奇怪的问题,不幸的是它的重现性不是很好,所以我对 go 没有太多了解。

I have a page in a WinForms application laid out as per the below.我在 WinForms 应用程序中有一个页面,如下所示。 Previously it was just a TableLayoutPanel anchored to the top, bottom, left and right, but now it is a Panel Docked into Fill mode with the same anchored TableLayoutPanel inside:以前它只是一个锚定在顶部、底部、左侧和右侧的 TableLayoutPanel,但现在它是一个 Panel Docked into Fill 模式,内部具有相同的锚定 TableLayoutPanel: Visual Studio 中页面的屏幕截图

On all computers I have been able to try it on (including with and without Windows' Zoom functions), it displays like the above.在我能够尝试的所有计算机上(包括有和没有 Windows 的缩放功能),它的显示如上。 However a small number of users experience a screen that looks like the below, with items clipped off screen (this user doesn't have access to the first tab, so it is hidden):然而,少数用户会遇到如下所示的屏幕,其中项目被截断(此用户无权访问第一个选项卡,因此它被隐藏): 在此处输入图像描述

Items are clipped off screen and because of the anchoring, resizing doesn't help, they just expand.项目被截断屏幕,并且由于锚定,调整大小无济于事,它们只是扩展。

I'm unsure how this is triggered but I think it could be something to do with the zoom of the machine being used for Visual Studio vs the zoom of the machine running the application;我不确定这是如何触发的,但我认为这可能与用于 Visual Studio 的机器的缩放与运行应用程序的机器的缩放有关; with that said I've tried running the application on various different zoom levels and can't reproduce the problem on my end.话虽如此,我已经尝试在各种不同的缩放级别上运行该应用程序,但最终无法重现该问题。 I have also tried adding a panel docked to Fill the area but that doesn't seem to have done much.我还尝试添加一个停靠在填充区域的面板,但这似乎并没有起到多大作用。

Is this something anyone has seen before with WinForms or can provide any suggestions?这是任何人以前在 WinForms 上见过的东西还是可以提供任何建议?

Based on the comment from @rene, I looked at the answers on Creating a DPI-Aware Application - the two parts of the answer that resolved it for me were:根据@rene 的评论,我查看了有关创建 DPI 感知应用程序的答案 - 为我解决该问题的答案的两个部分是:

  • Disable any scaling on the machine(s) being used for development在用于开发的机器上禁用任何缩放
  • Run a bulk string-replace across the application's code-base for this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;在应用程序的代码库中运行批量字符串替换this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; nand replace it with this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; n 并用this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; , and develop all future forms with the AutoScaleMode set to None ,并开发所有未来的 forms,并将 AutoScaleMode 设置为 None

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM