How to fit Windows Form to any screen resolution?

rajdh75

Active member
Joined
Mar 30, 2020
Messages
29
Programming Experience
Beginner
Hi,
I have made a project in windows form in visual studio community editon 15.
My all form was designed in 1024 x 768 resolution.
When I run setup on another pc or laptop the screen resolution does not matches.
If my clients using different resolution like 1600 x 1200 or 1600 x 900 or any other resolutions.
To solve this problem, i tried various codes in load page...but its not working properly.
Like Setting the System..WindowState property to FormWindowState.Maximized
OR
Form property Autosize = true, Form property Autosizemode=GrowAndShrink
OR
VB.NET:
Me.Location = New Point(0, 0)
Me.Size = Screen.PrimaryScreen.WorkingArea.Size
OR
VB.NET:
Dim h As Integer = Screen.PrimaryScreen.WorkingArea.Height
Dim w As Integer = Screen.PrimaryScreen.WorkingArea.Width
Me.ClientSize = New Size(w, h)
OR
VB.NET:
        Dim intX As Integer = Screen.PrimaryScreen.Bounds.Width
        Dim intY As Integer = Screen.PrimaryScreen.Bounds.Height
        If (intX < Me.Width) Then
            Me.Width = intX
        End If

        If (intY < Me.Height) Then
            Me.Height = intY
        End If
I attach two image for reference purpose. First is with 1024 x 768 resolution, second is with 1600 x 1200 resolution.
1024x768.jpg


1600x1200.jpg

If possible please tell me the code to resize window form to fit all resolutions.
Thanks in advance
 
You're trying to solve a problem that doesn't exist. The reason people increase their resolution is to fit more on the screen. If you just make everything bigger then you defeat the purpose. Just create your form the size you want it to be and then display it that size no matter the resolution, just like everyone else does. Stop trying to make things hard.
 

Latest posts

Back
Top