GDI+ Problem encountered in drawing multiples rect

2019-08-29 12:21发布

I whant to draw a table in C# Windows Forms using GDI+. When the number of rectangles is too large for all rectangles to be displayed on the form, it does not scroll. And can not access those who did not fit the form.

What I need to do to see everything I drawing on the form?

Thanks.

2条回答
趁早两清
2楼-- · 2019-08-29 12:30

Create a UserControl where you draw your table. Set its Height and Width to the full height and width (i.e. not restricted to the form size, but related to the table size). Now put your control in a Panel and activate scroll bars there.

查看更多
做个烂人
3楼-- · 2019-08-29 12:42

Use a Panel or UserControl for drawing, make it large enough that your complete table fits and then let the form auto-scroll.

A component doesn't care about what you draw on it or where. Scrollbars do not magically appear just because you're drawing something in a place where it can't be seen. So either use a component lage enough that your drawing fits (you should know how large it gets) and let the container scroll. Or use scrollbars directly and translate your drawing accordingly. The latter option is more complicated, though :)

查看更多
登录 后发表回答