Updating Progress Bar with double
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Updating Progress Bar with double

  1. #1
    Join Date
    Jun 2009
    Posts
    6

    Updating Progress Bar with double

    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?

  2. #2
    Join Date
    Oct 2008
    Location
    Cologne, Germany
    Posts
    756

    Re: Updating Progress Bar with double

    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
    win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming

    remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation

    private lessons are not an option so please don't ask for help in private, I won't replay

    if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know

  3. #3
    Join Date
    Jun 2009
    Posts
    6

    Re: Updating Progress Bar with double

    Thanks! Can't believe i did not notice that....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center