Consider a UserControl to which you do
userControl.Pai nt += new PaintEventHandl er(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.WriteLi ne( ) in the paint method so you know
when its getting called. Also there is no place in the code that
userControl.Pai nt 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.Inv alidate(), userControl.Ref resh() 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.Pai nt
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.Pai nt
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(use rControl, new
PaintEventArgs( userControl.Cre ateGraphics(), new
Rectangle(0,0,u serControl.Widt h, userControl.Hei ght)));
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!