Question

I am creating a simple Windows form application using Visual C#.

The form is can re-sized by the user (by click and drag). But, I don't want the user to decrease the dimensions of the form beyond a certain limit. How can I set the limits?

Was it helpful?

Solution

Go to your form in VS and press F4 to get to the properties of the form and look for the MinimumSize property:

enter image description here

To set the size from code use:

this.MinimumSize = new Size(100, 100);

Note that this does not prevent minimising/maximising the form! If you want to prevent this, then set the MaximizeBox property to false.

OTHER TIPS

In the WinForm properties there is minimum size property see here http://msdn.microsoft.com/en-us/library/system.windows.forms.form.minimumsize(v=vs.110).aspx

To change it on run-time:

int width, height;
this.MinimumSize = new Size(width, height);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top