Winforms ProgressBar Takes time to Render

前端 未结 7 1642
清歌不尽
清歌不尽 2021-01-15 10:12

I have noticied that when using the PorgressBar. If I set the value to x, the value displayed is not immediately updated, it takes a small amount of time to draw it as the b

7条回答
  •  滥情空心
    2021-01-15 11:07

    I have good results with progressbar lag, setting the value with this function:

    Private Sub SetProgressNoAnimation(ByVal value As Integer)
        ' To get around the progressive animation, we need to move the 
        ' progress bar backwards.
        If (value = progressBarCarga.Maximum) Then
            ' Special case as value can't be set greater than Maximum.
            progressBarCarga.Maximum = (value + 1)
            ' Temporarily Increase Maximum
            progressBarCarga.Value = (value + 1)
            ' Move past
            progressBarCarga.Maximum = value
            ' Reset maximum
        Else
            progressBarCarga.Value = (value + 1)
            ' Move past
        End If
        progressBarCarga.Value = value
        ' Move to correct value
    End Sub
    

    More information:

    https://derekwill.com/2014/06/24/combating-the-lag-of-the-winforms-progressbar/

提交回复
热议问题