可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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.
回答1:
You'll have to set the SizeMode
property to AutoSize
which causes the PictureBox to automatically resize to the picture's size.
回答2:
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
.
回答3:
The picturebox should not be anchored bottom and right. Instead, resize it to the content to display.
回答4:
For me below code helped in adding scrollbar:
Panel2.Controls.Clear(); Panel2.AutoScroll = false; Panel2.VerticalScroll.Enabled = true; Panel2.VerticalScroll.Visible = true; Panel2.AutoScroll = true;
回答5:
Change the Panel's Border Style to Fixed Single and then the Panel's Auto Scroll Property to True.