Form Resize

Rastlin

New member
Joined
Dec 5, 2006
Messages
2
Programming Experience
1-3
Hello,

In my form, on button click i resize the form.
FirstClick : size = 1000, SecondClick : size = 300 (Same Button)
The reference point is in the left, i want to change the refrence point to the right.

when the form changes to size 1000 i want the form to "grow " to the left
and not to the right how can i do this ?

thanks in advance
 
So you want to make it 'grow' in

<--

direction?

Well seeing as forms are normally resized from the bottom right you'll need to manipulate two properties at once. Is this just a straight forward resize or are you looking for some animation too? Straight resize would be that you will need to subtract the amount you want it to grow from the x position of the forms location. For example to make a from grow by 50 to the left..

VB.NET:
Form.Location = New Point(Form.Location.X-50,Form.Location.Y)
Dim GrowWidth As Integer = 50
Dim CurrentWidth As Integer = Form.Width
Form.Width  = (GrowWidth + CurrentWidth)
 
Actually, I lied. The Form class has a public SetBounds method and a protected SetBoundsCore method. The SetBoundsCore method seems to provide the best performance because it allows you to specify which aspects of the control are changing to avoid unnecessary work. Here's my previous code rewritten using this method:
VB.NET:
Dim increment As Integer = 100

Me.SetBoundsCore(Me.Left - increment, _
                 Me.Top, _
                 Me.Width + increment, _
                 Me.Height, _
                 BoundsSpecified.Width Or BoundsSpecified.X)
 
Back
Top