slow painting of controls

  • Thread starter Thread starter T!
  • Start date Start date
T

T!

Hi,

I have the following problem using c#.net.
I created my own button class inherited from Control to be responsible for
drawing my button. In my application I create 20 buttons of my own button,
something like a keyboard.
In my OnPaint event I do someting simple like graphics.fillrectangle.
The problem is that the drawing of the buttons is very slow, for example: if
i create these buttons in a loop I can see them being drawn one at a time.
For comparison reasons I placed a normal button on an empy form and in its
onclick event I use the same loop as for my buttons but instead of creating
buttons I simply make a call to graphics.fillrectangle and all the
rectangles are created in a flash!
Does anybody know if there is anyway to speed up the processing painting
Controls???

thnx in advance
 
Use FillRectangle on an off-screen bitmap and blit it to the image when
you're done.
 
Just to add my two cents - you might consider arranging all buttons into a
single control - this would speed up painitng significantly. By single
control I mean not a composite control, but a custom control
 
Back
Top