Is it possible to set the Maximum Width for a Form but leave the Maximum Height Unrestricted?

前端 未结 3 927
一整个雨季
一整个雨季 2021-01-11 18:30

For some reason if you set both of the width and the height of Form.MaximumSize to zero it will let you have an unrestricted window size, however if you want to set a limit

3条回答
  •  悲哀的现实
    2021-01-11 19:01

    I know the question is a couple of years old but I met the same problem and what I did was to set one of the parameter to the resolution of the screen, assuming the size of the form cannot exceed the size of the screen.

    this.MaximumSize = new Size(200, Screen.PrimaryScreen.Bounds.Height);
    

    Hopes this helps someone.

提交回复
热议问题