PaintEventArgs becoming empty -> black screen

D

DraguVaso

Hi,

To get faster performance of my DataGrid during scrolling I wanted to build
a timer in the Paint-event that waited some milli-seconds to Paint and
cancelled the method in case it received a new Paint (during scrolling).

But it doesn't seem to work :-(

The whole screen becomes empty, and when I look into the PaintEventArgs it
returns several errors (for exemple: ?petmr.Graphics.Clip -> <error: an
exception of type: {System.ArgumentException} occurred>).

Does anybody knows a solution for this?

Thanks a lot in advance!

Pieter

This is my code:
Protected Overrides Sub OnPaint(ByVal pe As
System.Windows.Forms.PaintEventArgs)
'my override
'stop the timer
tmrPaint.Stop()
'store the PaintEventArgs
peTmr = pe
'restart the timer
tmrPaint.Start()
End Sub

Private Sub tmrPaint_Elapsed(ByVal sender As Object, ByVal e As
System.Timers.ElapsedEventArgs) Handles tmrPaint.Elapsed
'call my paint-method
SubOnPaint(peTmr)
End Sub

Private Sub SubOnPaint(ByVal pe As System.Windows.Forms.PaintEventArgs)
'do all the painting stuff with MyBase.Paint etc etc
End sub
 
C

Chris

DraguVaso said:
Hi,

To get faster performance of my DataGrid during scrolling I wanted to build
a timer in the Paint-event that waited some milli-seconds to Paint and
cancelled the method in case it received a new Paint (during scrolling).

But it doesn't seem to work :-(

The whole screen becomes empty, and when I look into the PaintEventArgs it
returns several errors (for exemple: ?petmr.Graphics.Clip -> <error: an
exception of type: {System.ArgumentException} occurred>).

Does anybody knows a solution for this?

Thanks a lot in advance!

Pieter

This is my code:
Protected Overrides Sub OnPaint(ByVal pe As
System.Windows.Forms.PaintEventArgs)
'my override
'stop the timer
tmrPaint.Stop()
'store the PaintEventArgs
peTmr = pe
'restart the timer
tmrPaint.Start()
End Sub

Private Sub tmrPaint_Elapsed(ByVal sender As Object, ByVal e As
System.Timers.ElapsedEventArgs) Handles tmrPaint.Elapsed
'call my paint-method
SubOnPaint(peTmr)
End Sub

Private Sub SubOnPaint(ByVal pe As System.Windows.Forms.PaintEventArgs)
'do all the painting stuff with MyBase.Paint etc etc
End sub

don't you need to do a mybase.onpaint(...)

chris
 
D

DraguVaso

Yes it's indeed a MyBase.OnPaint(pe) etc.
But the problem isn't in that part, because everything works fine without
the timer (but just not as fast as I would like to have it).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top