DotNetWebTutor.com                                                    Link to Us

Position and Size
The position of the form is determined by x and y distance from top-left of screen

Controls position is determined by distance between top-left corner of its container (form or a container control)

size is determined by width and height of control from top-left corner
sizes and location of vb controls in form
all measurements are integers in pixels
properties
position:top, left, bottom, right
bottom and right cannot be adjusted
Size:width and height

set position by control.location.x and control.location.y
control.location=new point(xnum, ynum)
control.size=new size(widthnum, heightnum)

You can do size and position at same time
control.setBounds(xnum,ynum,widthnum,heightnum)

clientsize
Does not count scrollbars etc
visual basic clientsize
useful for placement calculations inside form
Example:
label1.location.y=(me.size.height-label1.height)/2
or
label1.location.y=(me.ClientSize.height-label1.height)/2
vb z-index
Z-Index
When control overlap there is a z-index that decides which control is on top

A z-index of 1 will appear above a control with z-index of 2

The last control you add is always on top by default
To get or set z-index use setchildindex() or getchildindex()
controls.setchildindex(ctrl,2)

To bring a control to front of index
right-click on control and bring to front or in code or send to back
control.bringToFront()
control.sendToBack()

Each container tracks z-index separately
vb controls aligning
Aligning
select control and set locked property to true so you do not accidentally move it
locking vb controls
As you move or resize control look for blue snap lines, they help you align the controls
snaplines
Snap Lines give visual feedback to line up controls and adjusting the control’s space to the edge of the form

From the menu:
format |Align |lefts to align to the lefts of the controls selected format align
format | makesamesize\width
format|verticalspacing|makeequal
format|center in form
visual basic controls properties