How can I get scrollbars in Picturebox

I have a PictureBox picture .

I use:

 picture.Size = bmp.Size; picture.Image = bmp; 

Let's say there are two integers maxWidth and maxHeigth .
I want to add a vertical / horizontal scrollbar to the picture when its size exceeds maxWidth and / or maxHeight . How can i do this?

+49
c # scroll winforms scrollbar picturebox
Jan 17 2018-11-11T00:
source share
4 answers

You can easily do this with Panel Control.

Insert the panel into your form, say panel 1 and set

panel1.AutoScroll = true;

insert PictureBox into Panel , say image and set

 picture.SizeMode = PictureBoxSizeMode.AutoSize; 

and install Image

 picture.Image = bmp; 

hope this helps

+104
Jan 17 2018-11-11T00:
source share

Here's a project in which the guy created an ImagePanel user control that can be omitted from the form; It gives you scrollbars and scalability.

http://www.codeproject.com/KB/graphics/YLScsImagePanel.aspx

+4
Jan 17 2018-11-11T00:
source share

Another suggestion is to place the image in the FlowlayoutPanel.

Set Auto Scroll FlowlayoutPanel to true and set the image size mode to normal

Using the FlowlayoutPanel ensures that the image is always at 0.0 on the panel.

0
Apr 13 '16 at 1:31 on
source share

I got it to work, also putting the picture in the control panel, I set the Panel AutoScroll property to true, but I also set the Panel Autosize property to True, and the Panel Dock property to fill (this way when the user resizes the form - so there will also be a panel). For Picturebox, I set the Dock property for it to None, and SizeMode to Autosize (so it also changes when changing the size of the panel and form. It worked like a charm, Picturebox had scroll bars and when the user resizes the form - everything is still set correctly!

0
Jun 21 '16 at 19:56
source share



All Articles