tags:

views:

1048

answers:

3

I have a panel with a picturebox on it. When the content of the picturebox is too large I want scrollbars. I've set the autoscroll set to true on the panel. But when the content of the picturebox is larger then the height of the panel/picturebox no scrollbars are shown.

My panel is anchored top, left, bottom, right. The picturebox is also anchored top, left, bottom, right.

+2  A: 

The picturebox should not be anchored bottom and right. Instead, resize it to the content to display.

Henrik
+5  A: 

You'll have to set the SizeMode property to AutoSize which causes the PictureBox to automatically resize to the picture's size.

And I think you should drop the anchors and only anchor to the top left. The rest is taken care of automatically by the panel. Because otherwise the PictureBox would probably honor the anchors, being unable to resize itself larger than the panel it contains – leading to no scrollbars again.

Joey
+1  A: 

from MSDN:

There is currently a limitation in Windows Forms that prevents all classes derived from ScrollableControl from acting properly when both RightToLeft is enabled and AutoScroll is set to True. For example, let's say that you place a control such as Panel—or a container class derived from Panel (such as FlowLayoutPanel or TableLayoutPanel)—on your form. If you set AutoScroll on the container to True and then set the Anchor property on one or more of the controls inside of the container to Right, then no scrollbar ever appears. The class derived from ScrollableControl acts as if AutoScroll were set to False.

serhio