Hi,

my app does not contain a web component but it does download images from the web into pictureboxes.

I am trying to figure out how to code a progressbar on my app that would start when the form is loaded and increase gradually until all the pictureboxes have been populated with the images.

I have searched the net and found numerous examples, which in most cases turn out not to work at all or they are just fake progressbars.

I know that this should be possible.

Kind regards..,

MT ;)

Recommended Answers

All 3 Replies

There is a ProgressBar control available as standard on Winforms.
Add the control to your form, set the maximum and minimum values, then increment its Value property to show progress.
You dont have to use 1 to 100 for the max and min, if for instance you were loading 35 pictures you could set the min to 1, the max to 35, then increment the value by 1 for each picture that has finished loading.

There is a ProgressBar control available as standard on Winforms.
Add the control to your form, set the maximum and minimum values, then increment its Value property to show progress.
You dont have to use 1 to 100 for the max and min, if for instance you were loading 35 pictures you could set the min to 1, the max to 35, then increment the value by 1 for each picture that has finished loading.

Hi,

thanks for replying.

I knew there is a ProgressBar control available, I was just having issues at getting it to increment as I wanted it.

I will try as you suggest.

Kind regards..,

MT ;)

Right, got it sorted.

pb.LoadCompleted += delegate(object s, AsyncCompletedEventArgs e)
                { progBar.PerformStep();
                if (progBar.Value == 5)
                {
                    progBar.Visible = false;
                }
                };

I have 5 PictureBoxes (pb) on my form that are created at runtime.

Using the code above, the ProgressBar is incremented by 1 step each time a PictureBox.LoadCompleted event occurs up to the max of 5 and then the ProgressBar disappears.

Exactly what I wanted.

I am trying now to implement a custom ProgressBar to allow me to customize the colours without disabling VisualStyles.

Regards..,

MT ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.