Question

I am currently getting the status of files getting sent to a webservice to be displayed in a richTextBox however for demonstration purposes I would prefer it to be shown as a progress bar.

so far my code is -

        richTextBox1.Text = richTextBox1.Text + action + "ok: " +  ok.ToString();
        richTextBox1.Text += "\r\n";
        richTextBox1.Text = richTextBox1.Text + "err: " + err.ToString();
        richTextBox1.Text = richTextBox1.Text + "\r\n";

This works fine but I really think a progress bar would look better, I have trieda couple of things i.e -

        progressBar1.Equals = action;

But this doesn't seem to work, any input is greatly appreciated.

Was it helpful?

Solution

To work with a progress bar you have to set a minimum of 2 values:

The first value is Maximum and indicates the max value of your value bar (for example the total number of files to trasnfer)

Then, every time you want to update the bar you have to set the Value properties that indicates the current position of the bar (for example the number of files you actually transferred)

To be sure the bar receive a correct visual update in a form, you have to call Application.DoEvents() if you are doing your update in a loop

OTHER TIPS

http://msdn.microsoft.com/en-us/library/system.windows.forms.progressbar.value.aspx

You really should accept some answers in order to get better answers

I think you should look a bit further in the working of the progressbar. It accepts a Value property which will set the progress of the bar, together with the Min and Max properties.

So I assume you know how many files are being transferred to the webservice, set this value to the Max property of the progressbar, and after every file has been transferred increase the Value property of the progressbar.

Additionally to the properties mentioned by il_guru (Maximum and Value) you should also take a look at the values Minimum and Step. Then you can also use the function PerformStep() to let the progress bar increase its value.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top