How to implement a vertical and horizontal scroll bar in WinForms when using paint?

前端 未结 2 792
忘掉有多难
忘掉有多难 2021-01-22 20:58

In my code I draw a rectangle and usually the rectangle is too large for the screen, even when maximised. I have set the form property AutoScroll to true and this d

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-22 21:36

    Setting AutoScroll = true on a Control/Form alone will only ensure that all Controls you add/nest to the parent will either show or can be reached by the scrollbars which will show up as needed.

    This doesn't do anything for stuff you draw.

    To make the drawing scrollable you need to set the AutoScrollMinSize to large enough values.

    If you don't know in advance then at least while drawing you should be able to determine them from your data.

提交回复
热议问题