dcsimg
Results 1 to 3 of 3

Thread: [RESOLVED] How to enlarge image from center point of picturebox?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2016
    Posts
    8

    Resolved [RESOLVED] How to enlarge image from center point of picturebox?

    Hi, i want to enlarge the image gradually as i hover over it. Currently i managed to do so by using timer tick and method like below :
    PictureBox1.Size = New Size(PictureBox1.Width + 1, PictureBox1.Height + 1)

    However, when it is being enlarge, the location is fix at a upper-left point, and the image enlarge toward right bottom, which make the whole effect weird.
    Are there anyway i can make the image to enlarge as from center of the picture box?

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    40,115

    Re: How to enlarge image from center point of picturebox?

    In addition to changing the size, also change the location, eg:
    Code:
    PictureBox1.Location = New Point(PictureBox1.Left - 0.5, PictureBox1.Top - 0.5)
    I'm not sure if -0.5 will work, you may need to use -1 instead... and adjust your size change to +2 to compensate.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2016
    Posts
    8

    Re: How to enlarge image from center point of picturebox?

    Thanks!!!
    Using -1 and size change of +2 worked for me.
    Actually i had tried using this method beforehand. I used both -0.5 and -1 but -0.5 won't work as it need to be integer.
    And when i use -1, i don't realize i can just adjust the size change to +2.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width