How to attach a scroll bar to a picturebox
-
as topic, anyone can provide some codes that enable a scroll bar to a picturebox when the picture expand?
Drop 2 PictureBoxes on your form, so that Picture1 is Picture2's Container. Drop horizontal and vertical ScrollBar controls on proper positions around Picture1. Set Picture1.AutoSize = False and Picture2.AutoSize = True. As you load picture(s) into Picture2, execute the following code: If Picture2.Width > Picture1.Width Then ScrollBarH.Enabled = True Else ScrollBarH.Enabled = False End If If Picture2.Height > Picture1.Height Then ScrollBarV.Enabled = True Else ScrollBarV.Enabled = False End If Hope, it helps.
-
as topic, anyone can provide some codes that enable a scroll bar to a picturebox when the picture expand?
In my previous posting I forgot to mention that you control the position of Picture2 relative to Picture1 (which is a Container, remember?) with your scrollbars. The code to do that seems trivial enough: the horizontal scrollbar has to increment/decrement the Picture.Left, while the vertical one controls Picture2.Top properties.