Dear sir
My progress bar is not full fill (end area)and precentage is not center how can do it.please follow my attachment
thank you
wansa
Public Class Form1
Declare Auto Function SendMessage Lib "user32.dll" (ByVal hwnd As IntPtr, ByVal msg As Integer, ByVal wparam As Integer, ByVal iparam As Integer) As Integer
Enum ProgressBarcolor
red = &H2
green = &H1
Yellow = &H3
End Enum
Private Shared Sub ChangeprogBarcolor(ByVal progressbar_name As Windows.Forms.ProgressBar, ByVal progressbar_color As ProgressBarcolor)
SendMessage(progressbar_name.Handle, &H410, progressbar_color, 0)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SendMessage(ProgressBar1.Handle, 1040, 2, 0)
Timer1.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
ProgressBar1.Value += 1
Me.ProgressBar1.Refresh()
UpdatePBar()
If ProgressBar1.Value = 100 Then
Timer1.Stop()
End If
End Sub
Private Sub UpdatePBar()
Dim x As Single
Dim y As Single
Dim percentage As String = CType((ProgressBar1.Value / ProgressBar1.Maximum * 100), Integer).ToString & "%"
Dim gr As Graphics = Me.ProgressBar1.CreateGraphics
Dim sz As SizeF = gr.MeasureString(percentage, Me.ProgressBar1.Font, Me.ProgressBar1.Width)
x = (Me.ProgressBar1.Width / 2) - (sz.Width / 2)
y = (Me.ProgressBar1.Height / 2) - (sz.Height / 2)
If ProgressBar1.Value >= 50 Then
gr.DrawString(percentage, New Font("Century Gothic", "11"), Brushes.LightGreen, x, y)
Else
gr.DrawString(percentage, New Font("Century Gothic", "11"), Brushes.Black, x, y)
End If
End Sub
End Class