archer_coal Posted June 12, 2003 Posted June 12, 2003 has anyone added scrollbars to a picturebox in Vb.NET? Ive done it in vb6 but some of the properties have changed or been done away with. The basic idea was using 2 pictureboxes and have the scrollbars scale using the negative value of one compared to the other. Any tutorials, guidence or tips would be appreciated. Thanks Quote
Hamburger1984 Posted June 12, 2003 Posted June 12, 2003 I would suggest using a Panel instead of a picture box to display and scroll an image: Dim myBMP as Bitmap = New Bitmap("C:\myImage.jpg") 'load the Image Panel1.Size = New Size(500, 400) 'your panels default size... 'when the Image is smaller than the Panels size decrease the 'Panels size so there is no tileing... If myBMP.Width < Panel1.Width Then Panel1.Width = myBMP.Width End If If myBMP.Height < Panel1.Height Then Panel1.Height = myBMP.Height End If Panel1.BackgroundImage = myBMP 'Display the image Panel1.AutoScroll = True 'enable scrolling.. Panel1.AutoScrollMinSize = Panel1.BackgroundImage.Size I hope this is gonna help you! Quote
mhsueh001 Posted December 13, 2004 Posted December 13, 2004 An update for this post. Thanks Hamburger1984, this works great. Just to add an additional note, for multiple image files, the routine has a memory leak. The fix should be before you try to load up the new image, make sure you dispose of the previous one. If Not Panel1.BackgroundImage is nothing then Panel1.BackgroundImage.Dispose() End If Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.