none
Faster control rendering RRS feed

  • Pregunta

  • Hi everyone,

    I am having a bit of an issue with a windows form application. I have a rather large number of custom controls that are are added as child controls to a panel, and whenever this panel is resized (or created), each one of these controls has to be resized. Now, programmatically, this is an incredibly trivial task. However, the rendering occurs as soon as one control is resized, so it ends up being rather laggy because the whole form refreshes once for each control, instead of just recomputing the sizes of each, and then redrawing once at the end (which would be seamless!). Someone must have had similar performance issues because of this before, but I just don't know what to do about it, and can't find any info online.

    Any advice would be greatly appreciated! Thanks a lot!

    oliver
    miércoles, 5 de agosto de 2009 1:44

Respuestas

  • "Large number of controls" is inversely proportional to perceived drawing performance.  Get more than 50 of them and it starts to get pretty noticeable.  Check this thread for a possible quick fix.  Beyond that, start replacing controls with custom Paint and MouseClick handlers.

    Hans Passant.
    • Marcado como respuesta Kira Qian martes, 11 de agosto de 2009 8:27
    miércoles, 5 de agosto de 2009 11:13
    Moderador

Todas las respuestas

  • "Large number of controls" is inversely proportional to perceived drawing performance.  Get more than 50 of them and it starts to get pretty noticeable.  Check this thread for a possible quick fix.  Beyond that, start replacing controls with custom Paint and MouseClick handlers.

    Hans Passant.
    • Marcado como respuesta Kira Qian martes, 11 de agosto de 2009 8:27
    miércoles, 5 de agosto de 2009 11:13
    Moderador
  • OK, thanks very much for the answer! So, there is no way then to 'disable' automatic refreshing of a control temporarily? I presume not from the answer given (and I certainly haven't found a way), but it would be useful if I could tell a control to stop redrawing itself until it's done resizing the child controls, and then tell it to refresh only once.

    Thanks again - very appreciated!
    martes, 11 de agosto de 2009 13:37
  • Just hide them.

    Hans Passant.
    martes, 11 de agosto de 2009 14:35
    Moderador