Click to See Complete Forum and Search --> : Updating Progress Bar with double


mjstide
June 23rd, 2009, 12:21 PM
Basically I have a form that copys files from one location to another. When the copy begins it pops up with a new form that contains a progress bar control. The progress bar updates, on a seperate thread than the copy, everytime one file is copied over. The problem i am running into is, for example, if the user selects 35 files to copy over the progress bar does not update correctly. The user selects files from a checkedlistbox to copy. My code for the progress bar step looks something like this

ProgressBar probar = new Progressbar();
probar.step = (100/checkedlistbox1.checkeditems.count);

Then everytime a copy is complete i increment the progress bar. The problem with my earlier example is that the step has to be an int and 100/35 = 2.8..... So either the progess bar will not fill all the way up because it rounds 2.8 to 2 or it will fill over 100 if it rounds up to 3. So basically i was wondering how to help this, is there a way to increment the probar.value by a double value?

memeloo
June 23rd, 2009, 12:33 PM
a ProgressBar does not have to be from 0 to 100, you can adjust its Maximum property according to the file count, this way you don't have calculate anything

mjstide
June 23rd, 2009, 01:00 PM
Thanks! Can't believe i did not notice that....