Saturday, December 15, 2007

Scrollbar on a PictureBox, Nah!

The quickest way to add a scrollbar to a PictureBox is not to add one to it. Instead drag a Panel on the Form. Set its AutoScroll property to True.



Now, drag a PictureBox on this panel, such that the panel becomes the parent container of this PictureBox control. Set the SizeMode property of the PictureBox to AutoSize.



Ensure that you set the location of the PictureBox to 0,0. This will align the PictureBox to the top left of the Panel.

And... well nothing. That's it. You can load any image in the PictureBox at Design / Run time and the panel will do the rest for you.

No comments: