none
Possible bug of windows form designer

    Question

  • OS: Windows 10
    Visual Studio 2010 and Visual Studio 2015
    ===========
    I set Display scale = 100% and designed form for Windows Forms application. After that I changed display. The new display has the same phys. size, but has much more pixels. So I need to use display scaling setting.
     
    The following two sequences of operations lead to different results:
    1) Display Scale = 100% -> Restart computer -> Display Scale = 150% - > Start VS2010 -> Form looks perfect
    2) Display Scale = 150% -> Restart computer -> Start VS2010 -> Forms looks corrupted (fonts are scaled to 150%, size of text boxes - don't)...
    In both cases display is scaled to 150% just before starting VS2010, but my form looks different in Form designer.

    The same story with VS2015

    Sorry for bad English
    Wednesday, February 8, 2017 12:34 AM

Answers

  • Hi Andrey,

    The Windows Forms designer doesn't work well with retina (4K) displays and scaling settings. It modifies the following line, which should have always the 6F, 13F values:

             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

    The best workaround is to run Visual Studio in "dpi virtualization" mode, where it thinks that it is running at 100% scale (96 dpi) and doesn't modify those values. It will look blurred, but it won't "corrupt" your forms designers:

    Running Visual Studio or setups with DPI virtualization (DPI-unaware) on high DPI displays

    http://www.visualstudioresources.com/2017/01/13/running-visual-studio-or-setups-with-dpi-virtualization-dpi-unaware-on-high-dpi-displays/


    My portal and blog about VSX: http://www.visualstudioextensibility.com<br/> Twitter: https://twitter.com/VSExtensibility<br/> MZ-Tools productivity extension for Visual Studio: https://www.mztools.com

    Wednesday, February 8, 2017 3:32 PM

All replies

  • Hi Andrey Otroshenko,

    Welcome to the MSDN forum.

    Refer to your description, it looks like you mean the MainWindow form of the WPF project, right? I tried to create a new C#/VB—Windows Forms Application and there is no place to set display scale, so it should stand for C#/VB-WPF Application.

    In VS 2015---WPF project, open MainWindow.xaml and the default display scale about 60% and if I set it to 100% or 150% then save the project and close VS. Restart VS and open this solution, the display scale keep the value that you saved (100% or 150%), but if I choose to restart the computer after closing the VS, then restart VS and open this solution, the display scale return to the default value like 60%. The form looks fine and not meet the same issue as yours.

    Please have a try with the following to troubleshot this issue:

    1. Make sure windows update is up-to-date, the VS UI display affects by OS in some places.

    2. Reset the customized setting to the default setting, please go to Tool-Import and Export Settings—Reset all settings and save your current settings, then reset it.

    >> 1) Display Scale = 100% -> Restart computer -> Display Scale = 150% - > Start VS2010 -> Form looks perfect

    I have a little doubt about this scenario, it looks like the VS have not start, where did you operate this “Display Scale = 150%”, do you mean restart the computer and VS, then change the display scale to 150% and it display normally, right?

    Best regards,

    Sara


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, February 8, 2017 7:41 AM
    Moderator
  • My project is "Windows Forms Application" in Visual C#.
    There are several textboxes on main form of this application and there is some text in these textboxes
    I change display scale outside of the Visual Studio! Just before I start VS, I change display scale right-klicking desktop and choosing "Display settings".

    If my computer start with display scale = 150% - Windows Forms Designer in Visual Studio shows my forms corrupted and I cannot visually edit my form.
    If my computer starts with display scale = 100% and I change display scale to 150% just before starting Visual Studio, all is OK.

    Mentioned above sequences of operations will reproduce my situation on your computer.

    Just repeat these sequences several times and you will see yourself that outlook of the form in Forms designer changes according to the history of scale changing and not to the final scale. (in both cases display scale is 150% in the moment when VS starts). 

    Wednesday, February 8, 2017 8:44 AM
  • Wednesday, February 8, 2017 8:57 AM
  • Wednesday, February 8, 2017 8:58 AM
  • Hi Andrey,

    The Windows Forms designer doesn't work well with retina (4K) displays and scaling settings. It modifies the following line, which should have always the 6F, 13F values:

             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

    The best workaround is to run Visual Studio in "dpi virtualization" mode, where it thinks that it is running at 100% scale (96 dpi) and doesn't modify those values. It will look blurred, but it won't "corrupt" your forms designers:

    Running Visual Studio or setups with DPI virtualization (DPI-unaware) on high DPI displays

    http://www.visualstudioresources.com/2017/01/13/running-visual-studio-or-setups-with-dpi-virtualization-dpi-unaware-on-high-dpi-displays/


    My portal and blog about VSX: http://www.visualstudioextensibility.com<br/> Twitter: https://twitter.com/VSExtensibility<br/> MZ-Tools productivity extension for Visual Studio: https://www.mztools.com

    Wednesday, February 8, 2017 3:32 PM