Search code examples
.netvb.netformsscalingdpi

.NET Form Size Scaling Issues


I've created a small form in Visual Basic .NET. However, when opening the form, I've discovered that when the form's size have been set to a small size, like 67, 67, the form's window often becomes stretched.

I thought this was a high DPI scaling issue, as I'm using a high DPI screen, so I opened the application release file's Properties > Compatibility > Change High DPI settings and selected "Override High DPI scaling issues, scaling performed by Application" and I believed that it would solve the problem as usual.

However, I noticed that this did not fix the stretching of the form as I thought it would...

How can I fix this issue so that the actual form's size isn't stretched and reflects the form's size shown in the designer? There are some supplementary screenshots included below...

Designer:

Forms Designer

Form Properties:

Form Properties

Result from Debugging and Changing Compatibility Settings (Form Indicated by Blue Arrow) Result


Solution

  • Try setting the size in the form loading event. It worked for me.

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.Size = New Size(67, 61)
    End Sub