Windows size issue.

John Mazur 0 Reputation points
2023-02-25T12:58:18.82+00:00

HI there,
Recently I came up against a windows sizing issue.
In the designer I have specified a large form size, I have to scroll the see all of it.
My issue is after compilation the form is truncated, the whole form is not displayed. I have to drag the form larger to see the bottom of the form. This strikes me as 'odd behaviour'
Anyone else have this behaviour.
I'm using VB.Net 2022.
Thanks.

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,564 questions
{count} votes

2 answers

Sort by: Most helpful
  1. LesHay 7,126 Reputation points
    2023-02-25T13:26:11.47+00:00

    Hi

    Maybe on the wrong track here, but I have seen similar effects before.

    I think this is due to my windows settings rather than settings in VB. I need to use a larger font on my computer because it has such a high resolution that I can't even find the text let alone read it. Anyway, with my 'cure' for that, then VB doesn't behave quite normally. For example, I design a Form of a large size then when running the application, controls are 'off screen' etc and unusable etc.

    In these cases, all I needed to do, once I discovered it, was to go ahead and design as needed, but, before running the code, resize the Form in the designer to a small size and do any other resizing in code, making the Form size back to desired - this stopped VB from losing the controls and everything seems to be OK.

    As I said, maybe this is not the kind of issue you are seeing, if so just ignore this post.

    0 comments No comments

  2. Reza Aghaei 4,936 Reputation points MVP
    2023-02-25T23:56:27.1033333+00:00

    I guess it might be due to using a high DPI monitor. I'd suggest you do two things:

    • Making your application DPI aware.
    • Making sure VS WinForms Designer doesn't have DPI issue

    Making sue your Application is DPI aware

    Assuming you have a VB.NET WinForms project using .NET Framework >= 4.7, Open the app.config file and add the following section:

    <System.Windows.Forms.ApplicationConfigurationSection>
        <add key="DpiAwareness" value="PerMonitorV2" />
    </System.Windows.Forms.ApplicationConfigurationSection>
    

    Now if you run your application, what you see in run-time is what you design if design time.

    You may also want to take a look at the following resources to learn more about DPI awareness:

    One more thing that you should always consider, is using proper docking and anchoring or the controls; which helps the UI responds properly to changes in the size of form. To learn more, take a look at:

    Fixing VS WinForms Designer DPI Issues

    Since the Windows Forms Designer in Visual Studio doesn't have scaling support, display issues can occur when you open some forms on high dots per inch (HDPI) monitors. One option could be changing your DPI to 100%, but a better option is restarting Visual Studio as a DPI-unaware process, and using 100% scale. You can do so by selecting the option on the yellow information bar that appears when you open the form in the Windows Forms Designer.

    For more information take a look at: