How can I make the progress bar update fast enough?

后端 未结 9 1587
礼貌的吻别
礼貌的吻别 2021-02-08 20:40

I\'m using a progress bar to show the user how far along the process is. It has 17 steps, and it can take anywhere from ~5 seconds to two or three minutes depending on the weath

9条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-08 21:04

    Vista introduced an animation effect when updating the progress bar - it tries to smoothly scroll from the previous position to the newly-set position, which creates a nasty time lag in the update of the control. The lag is most noticeable when you jump a progress bar in large increments, say from 25% to 50% in one jump.

    As another poster pointed out, you can disable the Vista theme for the progress bar and it will then mimic the behavior of XP progress bars.

    I have found another workaround: if you set the progress bar backwards, it will immediately paint to this location. So, if you want to jump from 25% to 50%, you would use the (admittedly hackish) logic:

    progressbar.Value = 50;
    progressbar.Value = 49;
    progressbar.Value = 50;
    

    I know, I know - it's a silly hack - but it does work!

提交回复
热议问题