ProgressBar 未更新 VB.NET [英] ProgressBar not updating VB.NET

查看:49
本文介绍了ProgressBar 未更新 VB.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个进度条和一个控制它的计时器.但是由于某种原因,progressBar 没有更新,但是progressBar 的值随着定时器的运行而变化,我做了一些调试,UI 似乎没有更新progressBar,因为值和定时器工作正常.这是我的代码

I have a progressBar and a timer that controls it. But for some reason the progressBar is not updating however the value of the progressBar it is changing as the timer goes, I did some debug and the progressBar the UI seems to not update, because the value and the timer are working perfectly. Here is my code

     Private Sub timerReserve_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timerReserve.Tick
         If progressBar1.Value = progressBar1.Maximum Then
             timerReserve.Stop()
             ....(database updates)
         Else
             countdown +=1 
             progressBar1.Value += 1
         End If
     End Sub

我不知道发生了什么,它应该可以正常工作......

I don't know what is going on, it should work fine ....

提前致谢

推荐答案

在您的进度条属性中,将 STEP 属性设置为与您正在制作的 INCREMENT 相同的大小(您正在制作 +=1 增量)

In your Progress bar properties set the STEP property to the same size as the INCREMENT that you are making (you are making +=1 increments)

然后在您的计时器代码中,强制进度条显示更改.

And then in your timer code, FORCE the progress bar to display the changes.

Private Sub timerReserve_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timerReserve.Tick
  If progressBar1.Value = progressBar1.Maximum Then
    timerReserve.Stop()
    ....(database updates)
  Else
    countdown +=1 
    progressBar1.Value += 1
    ' ** FORCE UPDATE **
    progressBar1.PerformStep()
  End If
End Sub

这篇关于ProgressBar 未更新 VB.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆