views:

401

answers:

1

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?

+2  A: 

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.

Nicole Calinoiu
I'm not too sure about that because MaxWindowTrackSize limits the maximum size to the size of the display area. Although I've never found the need, I think a window is sometimes sized to larger than the screen area.It's annoying that the max size isn't defaulted to (-1,-1), where -1 means unlimited.
Jules
setting this in Designer(.cs) will not work...
serhio