My really awesome custom progress bar

Posts 1–8 of 8 · Page 1 of 1
My really awesome custom progress bar
I was working on it this morning, it isnt as good as the normal one... but it's something :P

-Project -> Add New Item -> UserControl and call it ProgressBar.

Code:
    Private Sub ProgressBar_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Size = New Size(100, 20)
    End Sub

    Private ProgressValue As Single = 0
    Private ProgressMaximumValue As Single = 100
    Private ProgressColor As Brush = Brushes.Green

    Public Property Color As Brush
        Get
            Return ProgressColor
        End Get
        Set(ByVal value As Brush)
            ProgressColor = value
        End Set
    End Property

    Public Property Value() As Integer
        Get
            Return ProgressValue
        End Get
        Set(ByVal Value As Integer)
            ProgressValue = Value
            Dim _Bitmap As New Bitmap(Me.Width, Me.Height)
            Dim _Graphics As Graphics = Graphics.FromImage(_Bitmap)
            _Graphics.Clear(Drawing.Color.White)
            _Graphics.FillRectangle(ProgressColor, New Rectangle(New Point(0, 0), New Size(Value / ProgressMaximumValue * 100, Me.Height)))
            _Graphics.DrawString(Value / ProgressMaximumValue * 100 & "%", New Font("Times New Roman", 12), Brushes.Black, New PointF(0, 0))
            Me.Refresh()
            Me.BackgroundImage = _Bitmap
        End Set
    End Property

    Public Property MaxValue() As Integer
        Get
            Return ProgressMaximumValue
        End Get
        Set(ByVal Value As Integer)
            ProgressMaximumValue = Value
        End Set
    End Property
-Now you can add it to your form from the toolbox.



-Some properties I've changed: (note: change all the other properties before the value.)

Code:
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ProgressBar1.Color = Brushes.Lime
        ProgressBar1.MaxValue = 200
        ProgressBar1.Value = 100
    End Sub
The control is very limited... so you can add new things to it and make it better :P
Not really awesome tho..
Quote Originally Posted by Biesi View Post
Not really awesome tho..
Meh... first time I've ever created anything like this so seems good to me :d
Can change the colour ?
Quote Originally Posted by Haochenglee View Post
Can change the colour ?
Code:
    Public Property Color As Brush
        Get
            Return ProgressColor
        End Get
        Set(ByVal value As Brush)
            ProgressColor = value
        End Set
    End Property
Code:
...
            _Graphics.Clear(Drawing.Color.White)
            _Graphics.FillRectangle(ProgressColor, ....
Color.White for background
ProgressColor for progress value


@OP Looks cool : p Basic, but a good place to start.
Quote Originally Posted by abuckau907 View Post
Color.White for background
ProgressColor for progress value


@OP Looks cool : p Basic, but a good place to start.
Cant change the green colour to another colour ? like blue ..
Quote Originally Posted by Haochenglee View Post
Cant change the green colour to another colour ? like blue ..
Code:
Progressbar1.Color = Color.Blue
Posts 1–8 of 8 · Page 1 of 1

Post a Reply

Similar Threads

Talk with us