Click to See Complete Forum and Search --> : centering a picture


avatar
November 21st, 1999, 06:54 AM
Does anyone know how to center a picture on a form every time it changes size? I could tell it the left and top every time but that would be incredibly tedious. At the moment I have 'next' and 'previous' that change the picture in the frame but each pic is a different size. Any help would be appreciated!

Aaron Young
November 23rd, 1999, 12:16 PM
Set the Picturebox AutoSize Property to True, then in the Picturebox Resize Event, place the code to center it on the Form, eg.

private Sub Picture1_Resize()
DoEvents
Picture1.Move (ScaleWidth - Picture1.Width)/2, (ScaleHeight - Picture1.Height)/2
End Sub




Aaron Young
Analyst Programmer
adyoung@win.bright.net
aarony@redwingsoftware.com