Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Custom ProgressBar Question

$
0
0
I am trying to use a panel and a picturebox as a progress bar.
The panel displays the background image and the picturebox displays
the fill bar. On the form I also have a progress bar with a max value
of 256. The fill bar image is 256px wide and starts with a width of 0px.

I have the form download a file and update the progress as it downloads.
Public Sub DownloadPatch()
        Using mywc As New System.Net.WebClient
            AddHandler mywc.DownloadProgressChanged, AddressOf pchanged
            AddHandler mywc.DownloadFileCompleted, AddressOf done
            mywc.DownloadFileAsync(New Uri(DownloadLink), My.Computer.FileSystem.CurrentDirectory & DownloadLocation & PatchName)
        End Using
    End Sub
    Sub pchanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs)
        ProgressBar1.Value = e.ProgressPercentage
        PictureBox1.Width = ProgressBar1.Value
    End Sub
    Sub done(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs)
        If e.Error Is Nothing Then
            MsgBox("Download Complet")
        Else
            MsgBox(e.Error.Message)
        End If
    End Sub


The problem is that while the progressbar maximum is 256 the bar
stops at 100 and does not fill completely. How would I go about
making it so that the bar's 100% value is 256?

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>