By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,819 Members | 887 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,819 IT Pros & Developers. It's quick & easy.

PaintEventArgs becoming empty -> black screen

P: n/a
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


Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies

P: n/a
DraguVaso wrote:
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
Nov 21 '05 #2

P: n/a
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).

"Chris" <no@spam.com> wrote in message
news:OY*************@tk2msftngp13.phx.gbl...
DraguVaso wrote:
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

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.