Click here to Skip to main content
Licence CPOL
First Posted 30 May 2008
Views 65,037
Downloads 3,742
Bookmarked 90 times

Custom ProgressBar Control

By | 8 Jun 2011 | Article
Easy to use ProgressBar Control with many properties
ProgBarPlus

Introduction

Why another Progress Bar? The Standard ProgressBar was too limited and I couldn't find a custom control written that did all that I wanted. This is a UserControl with lots of properties and versatility. It shows minimum to maximum value progress or infinite back and forth progress. It is simple to use, just drop it on the form, adjust the design time properties and use it like the normal ProgressBar.

Background

This was my first UserControl that implemented some design time properties including an expandable property with the ExpandableObjectConverter TypeConverter and ControlDesigner. I have expanded the Design-Time editing in Version 2.0 using the techniques explained here: UITypeEditorsDemo[^] (Because of the new Editors, a revamp of the Properties occurred so there are some differences from the previous version). The demo also illustrates how to use a component or runtime BackgroundWorker to run different threads.

Control Properties

Here is a list of the primary properties:

  • BarStyleFill

    The fill style for the bar. Solid, Patterns, multiple color blends, and Image

  • BarColorBlend

    The Colors and Positions used for Gradient fills

  • BarColorSolid, BarColorSolidB

    The Colors used for Solid and Hatch fills

  • FocalPoints

    The movable Centerpoint and Focus Scales for the color blends

  • Shape

    The shape of the bar. Rectangle, Ellipse, Triangle, and Text

  • BorderColor, BorderWidth

    Change the border properties

  • Orientation

    Horizontal or Vertical progress

  • FillDirection

    Horizontal Right to Left or Left to Right and Vertical Bottom to Top or Top to Bottom

  • Corners, CornersApply

    Adjust the corner radius and apply to the border, bar, or both

  • ForeColor, TextAlignment, TextAlignmentVert, TextWrap, TextPlacement, Shadow

    Adjust the color, alignments, wrapping, and if the text appears over the control or moves with the bar

  • TextShow, TextFormat

    Templates for what text to display:

    • None
    • Value = Just the Value
    • ValueOfMax = Formats the Value with the Max i.e. '22 of 100'
    • Percent = Just the ValuePercent with a percent sign
    • FormatString = Enter any text here:
      • Enter {0} where you want the Value to show.
      • Enter {1} where you want the ValuePercent to show.
      • Enter {2} where you want the Max to show.
        i.e. '{0} rows of data out of {2} processed'
  • BarType

    Display Min to Max progress or Back and Forth infinite progress

  • BarLength, BarLengthValue

    Bar continues to expand with the Value or a fixed length of the bar moves with the value

  • Min, Max

    The minimum and maximum value of the ProgressBar

  • Value

    The current value of the ProgressBar

  • ShowDesignBorder

    Show a dotted line in design mode only if there is no border

Control Methods

  • ValuePercent()

    Get the Percent the value represents

  • ResetBar(opt value)

    Sets the Value to MinValue or MaxValue

  • Increment(opt value)

    Increase the value by one or the value given

  • Decrement(opt value)

    Decrease the value by one or the value given

Using the Code

Once you get the Progress Bar looking the way you want, add some code. You can directly change the Value property or use the Increment/Decrement methods:

 With MyProgBarText
    .Max = 200
    .ResetBar()
    For i As Int32 = 0 To 200
        .Increment()
        // Add Your Code Here
    Next
 End With

For the Infinite Progress Bar, change the BarType and change the CylonRun Boolean value:

  MyProgBarCylon.BarType = MyProgBar.eBarType.CylonBar
  MyProgBar.CylonRun = True

Points of Interest

The SmartTag makes it easy to customize the Progress Bar. All the important properties are organized to simplify the process.

ProgBarPlus

History

  • Version 1.0 February 2008
  • Version 2.0 November 2008
  • Version 3.0 June 2011
    • Many design and layout fixes

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

SSDiver2112

Software Developer

United States United States

Member

I first got hooked on programing with the TI994A. After it finally lost all support I reluctantly moved to the Apple IIe. Thank You BeagleBros for getting me through. I wrote programs for my Scuba buisness during this time. Currently I am a Database manager and software developer. I started with VBA and VB6 and now having fun with VB.NET

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionNice Control! Pinmembersoupman618:12 4 Jan '12  
AnswerRe: Nice Control! PinmemberSSDiver211213:04 4 Jan '12  
GeneralRe: Nice Control! Pinmembersoupman618:03 5 Jan '12  
QuestionHow do I compile Pinmembertreaverh17:42 24 Nov '11  
AnswerRe: How do I compile PinmemberSSDiver211217:04 26 Nov '11  
GeneralImpressive PinmemberCIDev5:49 8 Jun '11  
GeneralCan't find the .dll Pinmembermikehilton7:31 11 Nov '09  
GeneralRe: Can't find the .dll Pinmembermikehilton8:12 11 Nov '09  
GeneralRe: Can't find the .dll [modified] PinmemberOnur Guzel0:04 27 Apr '11  
GeneralRe: Can't find the .dll PinmemberSSDiver21122:02 27 Apr '11  
GeneralInstalling the control in VB Pinmemberdedawson40249:30 20 Apr '09  
GeneralRe: Installing the control in VB PinmemberSSDiver211210:15 20 Apr '09  
GeneralRe: Installing the control in VB Pinmemberdedawson402410:53 20 Apr '09  
GeneralGood control PinmemberDonsw6:14 8 Feb '09  
Generalso good Pinmembertaziscool20:01 2 Jan '09  
GeneralAwesome PinmemberMember 448805518:43 30 Nov '08  
GeneralC# version PinmemberMember 37388603:23 28 Nov '08  
GeneralRe: C# version PinmemberSSDiver21123:33 28 Nov '08  
GeneralRe: C# version PinmemberMember 37388604:02 28 Nov '08  
GeneralRe: C# version PinmemberSSDiver21124:13 29 Nov '08  
GeneralRe: C# version PinmemberMember 373886022:16 30 Nov '08  
GeneralThread safety Pinmembersupercat95:39 24 Nov '08  
Generalcouldn't ask for much more Pinmembercarrotwater13:42 21 Aug '08  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 8 Jun 2011
Article Copyright 2008 by SSDiver2112
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid