我设计了一个网络浏览器。除了进度条,它工作正常。
这是我的代码:
Private Sub WebBrowser1_ProgressChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs) Handles WebBrowser1.ProgressChanged
ProgressBar1.Maximum = e.MaximumProgress
ProgressBar1.Value = e.CurrentProgress
End Sub
报告的错误是progressbar1.value应该在max和min之间 e.currentprogress = -1是不可能的
答案 0 :(得分:2)
值为-1表示“已完成下载”,如该属性的MSDN Library文章中所述。因此:
Private Sub WebBrowser1_ProgressChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs) Handles WebBrowser1.ProgressChanged
If e.CurrentProgress = -1 Then
ProgressBar1.Maximum = 100
ProgressBar1.Value = 100
Else
ProgressBar1.Maximum = e.MaximumProgress
ProgressBar1.Value = e.CurrentProgress
End If
End Sub
或者您可能希望使用-1来隐藏进度条。