Resizing
There are 3 form events related to resizing
Resize - fires when the form is being resized.
ResizeBegin - fires when the mouse is pressed and the resizing is initialized
ResizeEnd - fires when the mouse is released and the resizing has completed.
Me.Size = New System.Drawing.Size(100,100)
To remove the Resizing handle in the bottom left corner change the SizeGripStyle to Hide
You specify the size and position of both forms and controls by using objects such as Size and Point instead of the scalar properties such as Left, Top , Width and Height.
By default Size and Point are measured in pixels (not twips).
You cannot change the Width and Height of the size object because they are read only. The only way to change it is to assign a new Size object.
FormBorderStyle = SizeableToolWindow
Allowing resizing from all sides
Maximise Box = True - not displayed but allows the user to double click to maximise
Minimise Box = True - not displayed but allows the user to double click to minimise
FormBorderStyle = Sizeable
Allowing resizing only using the grip handle
Maximise Box = True - displayed on windows form
Minimise Box = True - displayed on windows form
This defines the position of the form
Me.Location = New System.Drawing.Point(20, 20)
This defines the size of the form
Me.Size = New System.Drawing.Size(300,300)
Move the screen to the upper left corner of the screens working area
Me.DesktopLocation = New Point(0, 0)
Windows Forms expose a SetBounds method which lets you set both the size and position in one operation
Me.SetBounds(20, 20, 300,300)
Me.SetDesktopBounds = New Rectangle(10, 10, 10, 10)
Bounds is a System.Drawing.Rectangle object that represents the external border of the control.
ClientRectangle is the Rectangle object that represents the internal area.
ClientSize is the Size object that represents the dimension of the internal area. This is read-only, although you can obtain the same result by using the SetClientSizeCore method.
Expands the picture box to cover the whole form's client area
PictureBox1.Bounds = Me.ClientRectangle
This is exactly the same although it will leave a 10 pixel margin near the left and right edges of the picture box and an 8 pixel margin near the top and bottom.
Dim objRectandle As Rectangle = Me.ClientRectangle
objRectangle.Inflate(-10. -8)
PictureBox1.Bounds = objRectangle
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext