Slow in form display

Is there any method to speed up the display and rendering of Windows Form In my application, my Windows forms containing around 50~150 controls. There are also some navigation button to hide one form and display another one. The delay occur during form showing up.

As I'm developing a POS, such kind of delay is not preferable. Is there any workaround to speed this up



Answer this question

Slow in form display

  • Dave Waterworth

    You can usually do a few tricks to make things somewhat more bearable.

    Set all controls properties (size, location, text, etc) before adding them to the Controls collection.

    Limit the number of containers (panels inside of panels inside of panels, etc).

    If you need to shift a lot of controls around, or swap them in and out, then place them in a panel, and remove the panel from the Controls collection temporarily while manipulating the controls within it.

    Basically, any operation that causes a control (or it's parent) to repaint will be slower if the control has been placed on the screen... so avoid that.



  • Polina159216

    We have customers using custom graphical objects for POS applications. It is essentially as the earlier poster described, except they use a retained mode system. You can create thousands of "controls" this way. You can see an example of something similar to POS here:

    http://www.vgdotnet.com/articles/translucent_calculator.shtml



  • dgaynes

    Thanks for your suggestion. I will try to remove some labels and make use of the Paint event. However, I got a lots of buttons in my Windows Form. How can I fix them I don't think it's wise to paint the button by myself as I'll lose a lot of default UI behavior (I mean the outlook).

    Meanwhile, will it hard to manage a Windows Form with both control and custom Paint event How can I position the controls properly in the designer

    Thanks!

    Regards,
    Alex


  • rod_r

    Thanks Keith for your advise. However, my controls are rather static in nature. That means once I have placed them in a specific location inside the Windows Form. Its position and size will not change when the program is running. My main concern is about the initial load time for each form instead. Is there anything that I can do to improve its performance I think limit the no. of containers should have and I have already done so. How about the control collection that you've mentioned Is there anything else that I can do


  • MtEvans

    Yes, once you get past about 50 controls or so, the cost of using .NET controls and their associated Windows window becomes obvious to the eye. Look into drawing onto a form with the Paint event rather than using a control to make the UI snappier. Labels are an obvious candidate. ToolStripItems are low-cost too.


  • AlexKL

    Not much else, I am afraid. Under this version of Windows Forms controls, when you have that many controls being displayed, you will definately notice a delay. Dealing with Window Messages and Paint events is just darn expensive (Reflector into the Control class to see just how much stuff is crammed in there!). Hence the popularity of "spash screens" over the years.

    You might be able to find another trick or two.. nothing else comes to mind though (at least nothing that would be better than a shameful hack).

    WPF might offer some relief, as I think it's content model doesnt typically lend to this kind of problem as quickly.



  • Slow in form display