CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 1999
    Posts
    21

    centering a picture

    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!


  2. #2
    Join Date
    Sep 1999
    Location
    Red Wing, MN USA
    Posts
    312

    Re: centering a picture

    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
    [email protected]
    [email protected]
    Aaron Young
    Senior Programmer Analyst (Red Wing Software)
    Certified AllExperts Expert

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured