• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

how can I horizontaly scroll a very wide bitmap gif or whatever across the form

I have a bitmap that is to wide to display completely in the picture box how can I progromaticly scroll the picture within the picture box without the use of scroll bars
  • 4
1 Solution
This needed a bit experimenting to get it right. Esp. the redraw bit for once the image goes inside the rectangle of the Picture control. But here you go. This scrolls to the left in steps of 5 pixels. Make -5 into 5 to do the reverse: scrolling to right.

Dim bmpTemp As New Bitmap(picSourceLarge.Image)
Dim graph As Graphics = Graphics.FromImage(bmpTemp)
Dim aPen As New Pen(New SolidBrush(Color.White), picSourceLarge.Width)
' erase background with white
Dim rect As New Rectangle(0, 0, picSourceLarge.Width, picSourceLarge.Height)
graph.DrawRectangle(aPen, rect)
' draw scrolled to the left image in a -5 pixel step
graph.DrawImageUnscaled(picSourceLarge.Image, New Point(-5, 0))
picSourceLarge.Image = bmpTemp

Open in new window

picSourceLarge in the code above is supposed to be your picture control on your form, having a picture that is too large, and without scrollbars.
glad it helped :)
Mike TomlinsonMiddle School Assistant TeacherCommented:
Or you could just put the UNSCALED PictureBox inside a Panel (without AutoScroll) and then simply change the Location() Property of the PictureBox to move it around in there...
haha, lol, funny. While I thought about it, all I thought of was the scrollbars, so I didn't even try. Of course you can remove them. Getting to late here. Was a nice exercise regardless and thanks for waking me up ;-)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now