当在面板上绘制线条时,滚动条不会出现在面板上 (C#)
我想在面板上画一些线条和矩形。 有时它不适合面板 我希望出现滚动条。 我将 AutoScroll 属性设置为 true,但它不起作用;(
I want to draw some lines and rectangles on a panel. Sometimes it does not fit in panel
and I want the scroll bar to appear. I set AutoScroll property to true, but it doesn't work ;(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将面板的 AutoScrollMinSize 属性设置为大于面板实际尺寸的值(例如,如果面板为 300 x 200,请将 AutoScrollMinSize 属性设置为 900 x 600)。 这将导致两个滚动条出现,并且您应该能够在更大的表面上绘图。
Set the panel's AutoScrollMinSize property to a something larger than the panel's real dimensions (for example, if your panel is 300 x 200, set the AutoScrollMinSize property to 900 x 600). This will cause both scrollbars to appear, and you should be able to draw on the larger surface.
您需要通过设置
AutoScrollMinSize
属性。 但另一个也许更简单的解决方案是让您的面板包含另一个面板控件,您可以在其中进行绘图。 然后,您可以简单地调整内部面板的大小以适合您的绘图,外部面板将根据需要自动提供滚动。You will need to tell the panel control that you are drawing outside of the visible bounds by setting the
AutoScrollMinSize
property. But another, perhaps simpler, solution would be to have your panel contain another panel control in which you do the drawing. Then you can simply resize that inner panel to fit your drawing and the outer panel will automatically provide the scrolling as necessary.