How to fit Windows Form to any screen resolution?

后端 未结 8 922
长情又很酷
长情又很酷 2020-12-13 18:22

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 so

相关标签:
8条回答
  • 2020-12-13 18:58

    Probably a maximized Form helps, or you can do this manually upon form load:

    Code Block

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

    And then, play with anchoring, so the child controls inside your form automatically fit in your form's new size.

    Hope this helps,

    0 讨论(0)
  • 2020-12-13 19:01

    You can always tell the window to start in maximized... it should give you the same result... Like this: this.WindowState = FormWindowState.Maximized;

    P.S. You could also try (and I'm not recommending this) to subtract the taskbar height.

    0 讨论(0)
提交回复
热议问题