Recipe 4.13. Limiting the Sizing of a Form


Problem

You want the user to be able to resize a form, but within limits.

Solution

Use the MinimumSize and MaximumSize properties of the form to limit the user's adjustments of the form's size. As with the standard Size property, these two properties encapsulate separate width and height values. Figure 4-16 shows these settings in use in the Properties panel.

Figure 4-16. MaximumSize and MinimumSize properties in use


Discussion

These properties do limit the size of the form, whether the user is resizing the form directly or your code sets the Size property. You will usually want to set the form's FormBorderStyle property to Sizable, and you must set the MaximizeBox property to False (or in some other way hide the maximize box, such as by setting the ControlBox property to False).




Visual Basic 2005 Cookbook(c) Solutions for VB 2005 Programmers
Visual Basic 2005 Cookbook: Solutions for VB 2005 Programmers (Cookbooks (OReilly))
ISBN: 0596101775
EAN: 2147483647
Year: 2006
Pages: 400

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net