Question Scrolling drawn lines into view are shown repeating after they come into view

rogerm

Member
Joined
Apr 6, 2007
Messages
15
Programming Experience
3-5
As I use autoscroll to bring drawn rectangles into view it redraws but does not erase. rectangles already in view are cleared and redrawn correctly. It is only the ones coming into view.

In the paint event I am using gr.clear(me.backcolor)

Am I not clearing a large enough area? If so how do I do that?
 
Private sub tabStorage_paint(ByVal sender as object,ByVal e as System.Windows.Forms.PaintEventArgs) Handles tabStorage.Paint
Dim drw as bitmap
drw=New Bitmap(tabStorage.Width, tabStorage.Height, e.graphics)
gr=graphics.Fromimage(drw)
gr.smoothingmode=SmoothingMode.HighQuality
gr.Clear(Me.BackColor)
gr.DrawRectangles(blkPen, bldgRect)
e.graphics.DrawimageUnscaled(drw,0,0)
gr.dispose
End Sub
 
When the Paint is raised, the entire control is drawn but only the parts that have been invalidated get painted. The drawing code is executed quickly but the actual painting of pixels to the screen is slow, so it is done as little as possible. If you scroll a control then only the part that has just come into view will be invalidated by default, so only that part will be repainted, leaving your old drawing still painted on the rest. You need to make sure that any area that needs to change is invalidated before a Paint event.
 

Latest posts

Back
Top