Control loading (too slow/flickering) - winform

Posted on 2004-11-29
Last Modified: 2008-03-06
I have developed an app that loads and delete controls (picturebox) during run time. When I click on a picture, the app takes me to a different page. The way that I did this was to "remove" and "add" controls to the main form. The problem is that I can actually see the controls being removed and added during run time.

I had developed the same app for the web (a web app). At the time I used "ondocumentready" for when loading the page up a message box (a div tag) would appear "Processing your request". That was cool because the images were completely loaded with javascript and when they were all done, they would immediately appear all at once in the browser.

I cannot emmulate the same with a winform. I have tried also "show" and "hide" instead of "add" and "remove". No help. Same problem again.

Does anybody know how to do this?

Question by:dudubravo
    LVL 48

    Expert Comment

    Try SuspendLayout before changing and ResumeLayout after changing. Form designer uses this in InitializeComponent function.
    LVL 15

    Expert Comment

    You could also add these to a panel that is not visible until they are all added.
    LVL 10

    Accepted Solution

    The LockWindowUpdate function of the Platform API could help, but the problem is that .net does too many platform invokes wich slows the whole thing down - even when you surpress the repaints, it will still be slow. Try to use less controls... or create your own controls wich use less platform invokes (but this would be very much work... :o(  )

    Author Comment

    ptmcomp, you're the man!

    I do appreciate the other advices though. I did try each one of them. Actually I thought AlexFM's would work (I read MS info on it) but it did not work after all. I dont know why. I really tried it, but no luck. The idea of the panel was also good but gives me the same problem.

    Using the LockWindowUpdate api was the shizzle, the that solved it. Thans a lot,

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    This video discusses moving either the default database or any database to a new volume.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now