Progress Bar

I have a progress bar whereby it should progress for every graph that is loaded.But upon executing the program, the progress bar will immediately hit 100 % even the graph had not been fully loaded. But my code is written such that the PerformStep is placed after the loading of graph. Please advice. Thanks

for (int i = 1; i <= load_graph; i++)

{

parent_form.flowLayoutPanel2.Controls.Add(new TrendChart(aIdea, root_source));

parent_form.progressBar1.TabIndex = 0;

parent_form.progressBar1.Maximum = 10000;

parent_form.progressBar1.Minimum = 1;

parent_form.progressBar1.Step = 2500;

parent_form.progressBar1.PerformStep();

}



Answer this question

Progress Bar

  • Muhammad Ali Inayat

    of course he does that.. because nothing stops her..

    the loop executes real fast..For visual effect you should try the Thread.Sleep(500) but this is not recommanded coz if u are working with just one thread.. that threa will sleep and you will lose the UI control

    Anyway.. i wanna make a progress bar that increments every time a control is loaded like textbox, button, label.. like those programs that when they appear they shou you a little form and a label that is fast changing : "Loading structures, panel, menus.." somthing like that coz i done that and maybe i can help you..


  • Vadim Volkov

    You reset the minumum, maximum and step property value everytime you loop. Change to code to:


    ProgressBar progressbar = parent_form.progressBar1;
    progressbar.Minimun = 1;
    progressbar.Maximum = _load_graph;

    for (int i = 1; i <= load_graph; i++)
    {
    parent_form.flowLayoutPanel2.Controls.Add(new TrendChart(aIdea, root_source));
    progressbar.Value = i;
    }




  • Micahfox

    hmm..
    Man could you tell us exactly what you wanna do


  • yaf23

    May I know how to reset the progressbar to 0 which is the minimum value

    Thanks


  • msafi311

    I had tried Thread.sleep, but it will actually slow down the loading of data. Is there any other way of doing it

    Please advice.


  • Gordo-Schlau

    man..

    and if yourprogress bar performs real fast it means that you dont really need a progressbar because there is nothing to show ... coz the progress is made realtime.. progressbar is not for just visual effect.. As you saw Setup use progress bar coz they really need to.. if you copy a 100MB program then u need the progressbar and i can asure you that the progress bar will have time to be painted...

    Anyway.. if i understood exactly what you wana to is to show the progress of InitializeComponent

  • ErinMartell

    bslim wrote:
    May I know how to reset the progressbar to 0 which is the minimum value


    progressBar.Value = progressBar.MinimumValue;



  • Tayfun AKCAY

    is what you want to do.. what i sad


  • Dorie Hannan

    Hi

    Could you check your MarqueeAnimationSpeed in progressbar properties.

    Hope this helps



  • Kosar Jaff

    This is because you never let the UI thread do any painting.

    You can either load the graphs in a background worker (or similar multi-threaded solution) so the UI remains responsive during the load or call Application.DoEvents after each call to ProgressBar.PerformStep to let it handle its paint messages (any other pending messages will also be processed).


  • Progress Bar