PC Review


Reply
Thread Tools Rate Thread

Control.Paint and onPaint( ) events gone missing

 
 
vooose
Guest
Posts: n/a
 
      6th Jan 2005
Consider a UserControl to which you do

userControl.Paint += new PaintEventHandler(paint_method)

If you don't like that way, and prefer to override onPaint( ) then the
problem stated below still exists (I tried both ways).

Imagine you have a Console.WriteLine( ) in the paint method so you know
when its getting called. Also there is no place in the code that
userControl.Paint is -+ so the event is *never* removed.

At some point, after the first call of paint_method, subsequent calls to
repaint are never fired. So it doesnt matter if i call

userControl.Invalidate(), userControl.Refresh() etc

the paint_method/onPaint( ) code is never executed.

My question is, does anyone know why non-user classes would ever remove
the ability to paint a component? Even if i add the userControl.Paint
event back in, the paint method fails to get called again. Its like
sometime after the first paint, someone has ticked the 'never repaint
ever ever again' checkbox.

Another thing that is annoying (when debugging this) is that I can't
seem to go

userControl.Paint

on the immediate window, or under the debugger explorer to find out its
actual value, so I could keep querying it and notice at what line of
code it goes missing.

In the end I was forced to do:

paintMethod(userControl, new
PaintEventArgs(userControl.CreateGraphics(), new
Rectangle(0,0,userControl.Width, userControl.Height)));

which seemed to get it working. But I'm still curious as to the
aforementioned error. Any thoughts?



Wal
--

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Override OnPaint vs Handle Paint event sanjusunny@gmail.com Microsoft Dot NET Framework Forms 4 6th Oct 2006 01:10 AM
Creating a UserControl... use OnPaint method or capture Paint event? jrhoads23@hotmail.com Microsoft VB .NET 3 12th Jan 2005 03:46 PM
Creating a UserControl... use OnPaint method or capture Paint event? jrhoads23@hotmail.com Microsoft Dot NET Framework Forms 3 12th Jan 2005 03:46 PM
Control.Paint gone missing vooose Microsoft C# .NET 5 14th Dec 2004 09:15 AM
Picturebox control and paint events =?Utf-8?B?a3RjdXRl?= Microsoft Dot NET 2 15th Nov 2004 07:13 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:24 PM.