I have this code:

If e.Delta <> 0 Then
            If e.Delta <= 0 Then
                If PictureBox1.Width < 500 Then Exit Sub 'minimum 500?
            Else
                If PictureBox1.Width > 2000 Then Exit Sub 'maximum 2000?
            End If

            PictureBox1.Size = New System.Drawing.Size(PictureBox1.Width + e.Delta / 1, PictureBox1.Height + e.Delta / 1)
            PictureBox1.Location = New Point(Control.MousePosition.X - PictureBox1.Width / 2, Control.MousePosition.Y - PictureBox1.Height / 2)
        End If

which zooms the PictureBox to the center of the cursor location, but when I insert the picturebox to a panel, the image does not properly zoom in to the center of the image, instead to the edge of the panel.

How would I fix this?

If you mean something like this...

1f7df5a709ed290e8a87f9ee08a132b2

Then I believe I can help. If you are still around and you haven't figure it out then let me know. I'm going to paste the code any way for other people to get a rough idea of whats happening behind the scenes.

Note: I think what your doing is resizing an actual picturebox, the picture box is inside a panel so the panel acts as a clipping area. What this code does is process the image in memory, and draws the centered zoomed image to the view picture box. The picturebox on the left is a visual representation of whats going on in memory.

It's 2013. Is everything ok?

I'm still using vb.net 2010 so I had to do a little fiddling but everything works just fine. I suppose I should upgrade (next system rebuild).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.