locked
ProgressBar - disable smooth animation RRS feed

  • Question

  • Hi,

    When I set the Value property on a ProgressBar, it doesn't immediately update the bar to that value, it instead shows a smooth animation of bar increasing to that value.

    For example, if Value == 0, and I set it to 100, the bar will slowly increase to that value. However, I don't want this behaviour; I want it to go to 100 immediately. By the time it reaches the value I want, I no longer need the bar anymore. Is there anyway to change this?

    I've read this is a problem specific to the Aero style. I don't want to disable it just for this though.

    Note: it seems to only do this going one way. If the Value is 100 and I set it to 0, it will change immediately.

    Thanks.

    Monday, January 5, 2009 3:01 PM

Answers

  • I tried both Blocks and Continuous and it's the same result for both.
    I don't want to use the Marquee style.

    I did find a messy workaround that does the trick:

    ProgressBarFile.Maximum = 101;
    ProgressBarFile.Value = 101;
    ProgressBarFile.Maximum = 100;

    Then I can set the Value to whatever I want. It's not the ideal solution, but it does work and I'll use it unless someone finds a better way.

    • Marked as answer by Bruce.Zhou Friday, January 9, 2009 1:24 AM
    Monday, January 5, 2009 6:23 PM

All replies

  • Posting code always helps.  Don't force people to read between the lines or guess.  I assume that your ProgressBar.Style....

    public System.Windows.Forms.ProgressBarStyle Style { get;  set; }  
        Member of System.Windows.Forms.ProgressBar  
     
    Summary:  
    Gets or sets the manner in which progress   
    should be indicated on the progress bar.  
     
    Return Values:  
    One of the System.Windows.Forms.ProgressBarStyle values.   
    The default is System.Windows.Forms.ProgressBarStyle.Blocks  
     

    ....is set for continuous.  What about using Marquee mode, which uses this property?

    public int MarqueeAnimationSpeed { get;  set; }  
        Member of System.Windows.Forms.ProgressBar  
     
    Summary:  
    Gets or the time period, in milliseconds,   
    that it takes the progress block to scroll   
    across the progress bar.  
     
    Return Values:  
    The time period, in milliseconds,   
    that it takes the progress block to scroll   
    across the progress bar.  
     

    Hope this helps.

    Rudedog  =8^D
    Mark the best replies as answers. "Fooling computers since 1971."
    Monday, January 5, 2009 5:48 PM
  • I tried both Blocks and Continuous and it's the same result for both.
    I don't want to use the Marquee style.

    I did find a messy workaround that does the trick:

    ProgressBarFile.Maximum = 101;
    ProgressBarFile.Value = 101;
    ProgressBarFile.Maximum = 100;

    Then I can set the Value to whatever I want. It's not the ideal solution, but it does work and I'll use it unless someone finds a better way.

    • Marked as answer by Bruce.Zhou Friday, January 9, 2009 1:24 AM
    Monday, January 5, 2009 6:23 PM
  •  Unless you have a typo, you appear to be taking advantage of a bug in the behavior, which is usually not a good idea because you never know when the bug might get fixed.  Some bugs will never get fixed and this is likely to be one of them.  But, no guarantees.

    I assume that animation speed has no effect on the other styles, huh.  I guess it shouldn't.  Would have been a similar bug in the behavior of a control which may soon become outdated.

    Rudedog  =8^D
    Mark the best replies as answers. "Fooling computers since 1971."
    Monday, January 5, 2009 6:53 PM
  • No there is no typo. I'm guessing when you set ProgressBarFile.Maximum = 100, it sees that Value is above the new maximum and automatically sets it to the new max so that it doesn't throw an exception. Anyway, I can always change it back.

    And yes, the animation speed only affects Marquee.

    I'd say the API should have been updated so the Aero behaviour can be disabled. Then again, it's a minor cosmetic issue so it's not a big deal.

    Thanks.

    Monday, January 5, 2009 7:12 PM
  • This is a problem with the Vista version of the ProgressBar control.  Even without Aero.  They forgot to include a style flag that turns that feature off.  ProgressBarRenderer ought to solve your problem.  But you'll lose the animated "shimmer".
    Hans Passant.
    Tuesday, January 6, 2009 3:45 AM