I'm trying to develop an application that draws a bar graph on a panel. Depending on the graph resolution, the graph have to be larger that the viewport so what I did is create usercontrol within my project, define the usercontrol autoscroll to true and then add a panel in it on which I draw my bar graph. For the paint event, I overriden the onpaint sub of the usercontrol in which I get a ref to the graphics of the inenr panel (my drawing plane).
Up to there, everything works as expected. The problem occurs if I try to scroll the scroll bar: the onpaint sub doesn't get called. I looked at a sample from MS ( and tried to find what was the difference between this application and mine (since they support autoscroll and that it works fine) and I found nothing except maybe the fact that they don't use an inner panel.
So now, 3 questions:
1- Is it better to override the onpaint sub or use the paint event (and why)?
2- How can I directly paint on the usercontrol and still get the autoscroll to show scrollbars (since it won't know to what extent I'm drawing)?
3- Why isn't the sub called on scrolls?
Thank you!
Up to there, everything works as expected. The problem occurs if I try to scroll the scroll bar: the onpaint sub doesn't get called. I looked at a sample from MS ( and tried to find what was the difference between this application and mine (since they support autoscroll and that it works fine) and I found nothing except maybe the fact that they don't use an inner panel.
So now, 3 questions:
1- Is it better to override the onpaint sub or use the paint event (and why)?
2- How can I directly paint on the usercontrol and still get the autoscroll to show scrollbars (since it won't know to what extent I'm drawing)?
3- Why isn't the sub called on scrolls?
Thank you!