Slow form with multiple user controls redraw

C

conset23

Hello.
I'm working with WinForm. It has 30 same user control, each with 4 buttons,
3 labels, 3 textboxes, 2 picture boxes and uses override onPaint to draw
gradient rectangle. Main form also has 2 panels with same gradient.
I'm trying to reduce drawing speed on form activation. But at the moment it
is too noticeable for each user control to be drawn.
Tried to use double buffering on main form and on each user control, looks
almost the same.
Any help appreciated.
 
D

Dave

Just in case, make sure that UserPaint and AllPaintingInWmPaint is true. DoubleBuffering requires these bits to be set.

You can attempt to cut down on the flicker and paint time by reducing the number of controls that you are using. You mentioned that
you are using 3 labels and 2 picture boxes. These can easily be represented through GDI without the use of a control. Less
messages in the message loop = faster response time. If you need hit detection for mouse events or other user-interaction with
these controls you'd have to implement that manually via the events of the container control, of course. Also, you'll lose
Form-based featuers that Controls provide such as docking, anchoring, tabbing, amoung others. The 2 panels can also be drawing (the
gradient) without the panels, but you'll lose Control containment that the Panel provides.

If you can reduce the number of controls you are using you will most surely notice a difference.
 
A

Alexas

And is there any other way except reducing controls number. UserPaint and
AllPaintingInWmPaint is true.

Maybe it is possible to draw all form at once, and deny drawing each user
control separately?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top