利用VB2005制作颜色渐变的进度条[组图](8)
'每个画笔填充颜色占用的宽度
height = CSng(Me.ClientRectangle.Height - BorderWidth)
'根据当前百分比所占用的宽度使用画笔填充颜色
For x = halfBorder To totalWidth Step barWidth
e.Graphics.FillRectangle(lstBrushes(idxColor), x, halfBorder, barWidth, height)
If idxColor < lstBrushes.Count Then
idxColor += 1
End If
Next
'当进度为100%的,使用最后一个画笔填充颜色.
If (x < (Me.ClientRectangle.Width - halfBorder)) And percentComplete = 1.0 Then
If idxColor < lstBrushes.Count Then
e.Graphics.FillRectangle(lstBrushes(idxColor), x, halfBorder, ((Me.ClientRectangle.Width - halfBorder) - x), height)
End If
End If
End Sub
End Class