Creating a "virtual" ScrollableControl?

I create my own very simple grid control. I decided to get from ScrollableControl (this is what the DataGridView does) and from there.

I have a lot of code to draw my cells, but it's hard for me to figure out how to use the scrollable part of ScrollableControl. It seems that the ScrollableControl is designed as a container of other controls, and the "auto" scroll functions are oriented around child controls that are outside the control.

I just want to set the β€œvirtual” area of ​​the control, so I get the scrollbars of the right size, and then create my own drawing in the control to create my own β€œview”.

I am basically very upset about this. What is the easiest way to make this work?

+4
source share
4 answers

You need to set the AutoScrollMinSize property to tell which area you are going to display.

+9
source

As far as I know, you will need to have a ScrollableControl child element located at the bottom of your virtual surface. Perhaps a PictureBox with a transparent image of 1 pixel.

FYI, you can look at SourceGrid either as an inspiration in design (it makes good use of the MVC pattern), or perhaps this will solve your problem and you won’t want to roll on your own.

EDIT: Doh! I am sure Michael's decision is the right / best. However, you can still take a look at SourceGrid.

+1
source

You can just dump it on the panel with scrollbars :)

0
source

Do not roll over, the level of customization you are looking for is much more relevant and promising in WPF. You can create your own control and place it in WinForms if the question of fork loading of your application is impossible.

-2
source

All Articles