Home > Back-end >  Items clipping off-screen for some users in WinForms application
Items clipping off-screen for some users in WinForms application

Time:07-28

I am experiencing a very strange issue, and unfortunately it is not very reproducible so I don't have a lot to go on.

I have a page in a WinForms application laid out as per the below. 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:Screenshot of page in 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. 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): enter image description here

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; 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?

CodePudding user response:

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:

  • 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; nand replace it with this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;, and develop all future forms with the AutoScaleMode set to None
  • Related