Quote Originally Posted by fryed View Post
What would keep the ZoomFactor property from updating? When I load a new image into the ZoomPictureBox, I check the size of the control vs. the size of the image and depending on the aspect ratio I attempt to set the ZoomFactor to size the image so it is fit inside the control. I attempt to use zoompicturebox.ZoomFactor = <some value> but the value is not updating.
The ZoomPictureBox does that automatically when you set its Image property. So you shouldn't have to do anything at all.

For example:

Dim wRatio As Double = splContainer.Panel2.Width / zpbImage.Image.Width
Dim hRatio As Double = splContainer.Panel2.Height / zpbImage.Image.Height
If wRatio < hRatio Then zpbImage.ZoomFactor = wRatio Else zpbImage.ZoomFactor = hRatio
I'm not sure how that works because I don't know what you are doing with splContainer.Panel2. But I suspect something is wrong with the logic. To fit an image to a box, what you need to do is this: If the picture is wider and flatter than the box, fit the image widthways. Otherwise fit it heightways. That's all! If you want a code example, look in the ZoomPictureBox code for a function called FitImage (or something like that).

BB