Search code examples
c#winformsc#-3.0desktop-application

How to fit Windows Form to any screen resolution?


I work on VS 2008 with C#. This below code does not work for me. My form was designed in 1024 x 768 resolution.

Our clients laptop is in 1366 x 768 resolution. To solve this problem, I set below code in Form Load event:

this.Location = new Point(0, 0);
this.Size = Screen.PrimaryScreen.WorkingArea.Size;

but the form does not resize as per screen resolution and bottom of my form gets hidden or cut or I miss the scroll bar.

Is there any way to solve this problem? Please show me the syntax.


Solution

  • Can't you start maximized?

    Set the System.Windows.Forms.Form.WindowState property to FormWindowState.Maximized