ProgressBar resets at 60%

后端 未结 4 665
花落未央
花落未央 2021-01-13 23:09

I have this code:

for(int k = 0; k<11; k++)
{
    pBar.Maximum = 10;
    pBar.Value = k;
    if (pBar.Maximum == k)
        pBar.Value = 0;
}
4条回答
  •  终归单人心
    2021-01-13 23:40

    If you switch to Classic mode, this glitch will be gone. The progress bar will appear fully drawn before being reset.

    This is because in Classic mode, the painting operation is synchronous and completes before the Value setter returns, but in the themed mode, there is some sort of animation played when you increase the value, and that takes some time to play.

    On contrary, when you decrease the value, there is no animation; the progress bar is shrinked immediately.

    This is why it appears only about 60% full: you decrease the value (which completes immediately) before the progress bar has time to draw the animation for the last several increments.

提交回复
热议问题