How to fit Windows Form to any screen resolution?

shamim picture shamim · Feb 22, 2011 · Viewed 189.8k times · Source

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. Thanks in advance

Answer

ppiotrowicz picture ppiotrowicz · Feb 22, 2011

Can't you start maximized?

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