[RESOLVED] [2005] Paint event not triggering
Hello everyone,
I am using GDI+ to paint the form,its labels and its groupboxes with a gradient color.
But the problem Im facing is that the paint event doesnt trigger sometimes for the groupboxes and labels as it does for the form.
What could be the problem for this?
Please help,
Thanks so much,
Re: [2005] Paint event not triggering
The Paint event is raised every time the control requires repainting, period. If the control doesn't require repainting then its Paint event is not raised. .NET tries to do as little painting as possible because it is very time consuming. I haven't tested it but it is quite plausible that the forms Paint event will be raised because the form itself has changed but the region occupied by a particular control has not changed so that control's Paint event is not raised. If you want to force a control to be repainted at any time then you can call its Refresh or Invalidate method. Again, you should avoid any unnecessary repainting, so it is preferable to call the Inavlidate method and specify the area that has changed. It takes much less time to calculate that area than it does to repaint the are athat hasn't changed.
Re: [2005] Paint event not triggering
Thanks Jm,Ill try the invalidate method.... [:)]
This problem was occuring inside a Tab control which contains a couple of group boxes...
Sometimes,the groupboxes didnt paint themselves as coded...but then i found a custom tab control and used it and removed all the groupboxes for now..
But I have to use the same in different places..Ill try it soon..
Thanks [:)]