Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the maximum width OR maximum height of a form in .net

I've been meaning to ask this question for a while.

It appears that if I want to set a maximum width of a form then I have to set a maximum height as well.

Is this right?

If so, which of the multitude of variables do I use, in this situation, to set the maximum form height to the height of the window?

Screen.PrimaryScreen.Bounds?, Screen.GetWorkingArea(New Point(0, 0))?

Eta: From further investigation, I think PrimaryScreen.Bounds and GetWorkingArea are the same.

Also, having thought a little more, should I put Int32.MaxValue into the height property instead of the max height of the window?

like image 669
Jules Avatar asked Nov 05 '22 19:11

Jules


1 Answers

Yes, you do have to set the max width and height together using a Size instance. If you do not want to limit one of the dimensions, you might want to consider using System.Windows.Forms.SystemInformation.MaxWindowTrackSize to get the max for the "unlimited" dimension.

like image 63
Nicole Calinoiu Avatar answered Nov 13 '22 02:11

Nicole Calinoiu