Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get scrollbars on Picturebox

I have 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 vertical/horizontal scrollbar to picture when its size exceeds maxWidth and/or maxHeight. How can I do that?

like image 514
Ichibann Avatar asked Jan 17 '11 04:01

Ichibann


People also ask

How do I add a scrollbar in Visual Studio?

Open the Scroll Bars options page by choosing Tools > Options > Text Editor > All Languages > Scroll Bars.


1 Answers

You can easily do it with a Panel Control

Insert a panel to your form, say panel1 and set

panel1.AutoScroll = true;

insert a PictureBox to the Panel, say picture and set

picture.SizeMode = PictureBoxSizeMode.AutoSize; 

and set the Image

picture.Image = bmp; 

hope this helps

like image 174
Binil Avatar answered Sep 21 '22 08:09

Binil