Я тут примерно набросал, можно произвести от UserControl или от Control - разницы нет.
| Код | Public Class MyProgressBar Dim _value As Int32 = 0 Public Property Value() As Integer Get Return _value End Get Set(ByVal value As Integer) _value = value Me.Invalidate() End Set End Property Dim _progressColor As Color = Color.Lime
Public Property ProgressColor() As Color Get Return _progressColor End Get Set(ByVal value As Color) _progressColor = value End Set End Property Dim _minimum As Integer = 0 Dim _maximum As Integer = 100 Public Property Minimum() As Integer Get Return _minimum End Get Set(ByVal value As Integer) _minimum = value End Set End Property
Public Property Maximum() As Int32 Get Return _maximum End Get Set(ByVal value As Int32) _maximum = value End Set End Property
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) MyBase.OnPaint(e) Dim progressWidth As Single = 0 Try progressWidth = (Me.Value / (Me.Maximum - Me.Minimum)) * Me.Width Catch ex As Exception End Try Dim progressRect As New RectangleF(0, 0, progressWidth, Me.Height) e.Graphics.FillRectangle(New SolidBrush(Me.ProgressColor), progressRect) End Sub End Class
|
|