How to fit Windows Form to any screen resolution?

2019-01-22 01:36发布

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

8条回答
beautiful°
2楼-- · 2019-01-22 02:34

simply set Autoscroll = true for ur windows form.. (its not good solution but helpful)..

try for panel also(Autoscroll property = true)

查看更多
Fickle 薄情
3楼-- · 2019-01-22 02:35
int h = Screen.PrimaryScreen.WorkingArea.Height;
int w = Screen.PrimaryScreen.WorkingArea.Width;
this.ClientSize = new Size(w , h);
查看更多
登录 后发表回答