1

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.

Ebikeneser
  • 2,582
  • 13
  • 57
  • 111
  • 1
    What is `progressBar1.Equals = action;` supposed to mean? That doesn't make sense, `Equals` is a method. – Daniel Hilgarth May 03 '11 at 09:06
  • Do I understand it correctly that you would like to display text in a progress bar? Usually a progress bar only shows the completed percentage of some operation. – Christian May 03 '11 at 09:07
  • I dont know how to implement a progress bar, thereofre this was just an attempt. – Ebikeneser May 03 '11 at 09:09
  • @Christian no I dont need any text, just a working progress bar that shows the status of the data getting sent would be perfect! Just not sure how to do it. – Ebikeneser May 03 '11 at 09:10

4 Answers4

4

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

il_guru
  • 8,383
  • 2
  • 42
  • 51
1

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

Scoregraphic
  • 7,110
  • 4
  • 42
  • 64
0

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.

Roger Far
  • 2,178
  • 3
  • 36
  • 67
0

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.

Oliver
  • 43,366
  • 8
  • 94
  • 151