Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GDI+ (onpaint override) and autoscroll

Status
Not open for further replies.

BKQc

Programmer
Jul 26, 2002
118
CA
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!
 
1) I use OnPaint to handle items that need to change for the paint event. I use Paint to do the actual painting functionality.
2)Can you go with your original solution, catch the autoscroll event and call your UserControl.Refresh method? .Refresh should raise a paint event
3)No idea.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
There's no event for autoscroll...
What do you mean by "handle items that need to change for the paint event"?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top