Public Class ProgressBarEx Inherits ProgressBar Public Sub New() Me.SetStyle(ControlStyles.UserPaint, True) End Sub Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs) Const Edge As Integer = 1 Dim width As Integer = e.ClipRectangle.Width * (Me.Value / Me.Maximum) - 4 Dim height As Integer = e.ClipRectangle.Height - (Edge * 2) Dim rect As New Rectangle(Edge, Edge, width, height) If ProgressBarRenderer.IsSupported Then ProgressBarRenderer.DrawHorizontalBar(e.Graphics, e.ClipRectangle) Else Dim outerRect As Rectangle = e.ClipRectangle outerRect.Width -= 1 outerRect.Height -= 1 e.Graphics.DrawRectangle(Pens.Black, outerRect) End If e.Graphics.FillRectangle(Brushes.Red, rect) End Sub End Class