Preventing a form from being resized

Elvarg

New member
Joined
Nov 29, 2005
Messages
4
Programming Experience
Beginner
How do I prevent a form from being resized by the user while reserving the options to have it resized via a sub procedure? As in

Me.Width = 448
Me.Height = 256

I tried setting in the designer maximumsize as 448,256 and minimumsize as 448,256, but I dont see how it is possible to specify the maximum/minimum sizes in a sub procedure rather than the designer. Specifying it in the designer is no use because my program will need to be resized in runtime, so the maximum and minimum sizes will need to vary to match the program's current size.

I need to SET the size, not GET it, and vb wont let me do it using
Me.MaximumSize() for example won't help.

Or just tell me another way to stop form resizing by the user.
 
Set the BorderStyle property of the form to one of the Fixed- variants and the user will be unable to resize it.

This is a WinForms issue and not an IDE issue so I've moved this thread to the WinForms forum.
 
Usually this code will be add inside load event:
VB.NET:
[COLOR=green]'Load event[/COLOR]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].ClientSize = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] System.Drawing.Size(500, 400)
[/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].FormBorderStyle = FormBorderStyle.FixedSingle
[/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].MaximizeBox = [/SIZE][SIZE=2][COLOR=#0000ff]False [/COLOR][COLOR=green]'will preserve form to bemaximized[/COLOR][/SIZE]

HTH
Regards ;)
 
Back
Top