Question Text inside ProgressBar's Problem.

capedech

Well-known member
Joined
Oct 29, 2008
Messages
62
Programming Experience
Beginner
Hi,
This is my code :
VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim Gr As Graphics = ProgressBar1.CreateGraphics
        Dim Percent As String = ""

        For I As Integer = 0 To 100
            Percent = I & "%"
            ProgressBar1.Value = I

            Gr.DrawString(Percent, SystemFonts.DefaultFont, Brushes.Black, _
              (ProgressBar1.Width - Gr.MeasureString(Percent, SystemFonts.DefaultFont).Width) / 2, _
              (ProgressBar1.Height - Gr.MeasureString(Percent, SystemFonts.DefaultFont).Height) / 2)
            ProgressBar1.Update()
            Threading.Thread.Sleep(10)
        Next I
    End Sub
The output :
The texts are overlapping. When the next text printed inside the ProgressBar, the previous text still there.

Please help me to correct my coding.

Thanks in Advance.

Regards,

Nb. I hope I put my thread in the correct location.
If not correct, My apologize for Admin for troubling u to move my thread.
 
Back
Top