Click here to Skip to main content
Click here to Skip to main content

A Smooth ProgressBar for everyone! Part Duex

, 28 Feb 2005
Rate this:
Please Sign up or sign in to vote.
A versatile ProgressBar control featuring vertical and horizontal mode, gradients and more.


I've completely reworked the code for my SmoothProgressBar and it now features the ability to show the foreground and background of the control with a gradient. This feature is optional and defaults to a solid foreground and background, just as the original SmoothProgressBar control had. I've decided to post this version as a new article in order that you may compare the code techniques with the original.


Please refer to the first article for background info about this control and my reason for creating it.

Using the code

I've added several new properties and changed a couple of things from the original control. I discovered that I could have a property named Step if it was declared with surrounding square brackets, i.e.:

 Public Property [Step]() As Integer

Declaring it without the square brackets causes an error because Step is a Keyword in VB, so Visual Studio complains: Keyword is not valid as an identifier.

I also changed the method name for incrementing the Value property from Stepit() to PerformStep() to make it easier to substitute this control for the ProgressBar included in .NET, since that is the name used in the .NET control.

To support the display of gradients, there are several new properties associated with the control. First of all, the ProgressBarColor property has been renamed to BarColor1. In addition, there is a BarColor2 property used to set the end color of the gradient blend for the bar (foreground). Of course there are also BackColor1 and BackColor2 properties with corresponding effect for the control's background colors.

The Horizontal property has been renamed to Orientation, and the Reverse property is now Direction. They are no longer Boolean, instead using values from Enums to more accurately describe their function.

New properties BarColorStyle and BackColorStyle default to Solid; to use gradient blends change these to Gradient. BarGradientMode and BackGradientMode enumerate the standard gradient direction values Horizontal, Vertical, ForwardDiagonal and BackwardDiagonal.

BarSigmaMode and BackSigmaMode default to Normal. When set to SigmaBell, the properties BarSigmaFocus, BarSigmaScale, BackSigmaFocus and BackSigmaScale are used to shape the bell-curve defining the center and falloff rate of the gradient(s). BarGradientStretch controls whether or not the gradient blend of the bar (foreground) stretches as the bar progresses. If this doesn't make sense, just download the sample code and play with these property values to get a better idea of what they are doing.

Points of Interest

I've abandoned the technique of calculating an update Region in the setter code portion of the Value property. This was originally done to allow updating only the portion of the control which had changed from the previous value. I've since decided it would be less code to simply Invalidate the entire control after changing the Value property, but this causes flicker when the control is repainted, ergo the update Region code. Instead I've inherited the control from Control instead of UserControl, and set the Style to use double-buffering to avoid flicker. This is done with the following statement, placed in the Sub New() after the call to InitializeComponent():

Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.DoubleBuffer _
      Or ControlStyles.UserPaint, True)

It's worth noting that the UserPaint style only applies to classes derived from Control.

Another point worth noting is that some of the properties from Control aren't needed for SmoothProgressBar, and are suppressed from being shown in the PropertyGrid by setting the Browsable attribute to False. Here's an example:

<Browsable(False)> _
   Shadows ReadOnly Property Font() As Font
         Return MyBase.Font
      End Get
   End Property

The property must be declared Shadows or Visual Studio complains:

property 'Font' shadows an overridable method in a base class. 
To override the base method, this method must be declared 'Overrides'.


I think this will be my final effort towards creating a better ProgressBar, I'm fairly satisfied with the results. Please download the source and the demo project, compare it with the first article and leave a comment! I noticed that the original article has nearly 2500 views but has been rated by only two people, so if you like this article and this control (or even if you don't like it) please take a moment to give it a rating. I'm waiting to hear from you!


  • Feb 19th, 2005
    • Initial release.
  • Feb 28th, 2005
    • Added containing SmoothProgressBar.chm help file and SPB.xml for Intellisense support in Visual Studio (see the Read Me.txt file in the download for details).


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author


United States United States
No Biography provided

Comments and Discussions

GeneralRe: Great, but can't get IntelliSense to work PinmemberStumpy84229-Jun-06 17:35 
GeneralSettings not saving correctly. PinmemberVTHoodlum14-Mar-06 4:20 
GeneralRe: Settings not saving correctly. PinmemberPatrick Sears5-Apr-06 12:02 
GeneralCan't get it to work PinmemberDan Demp14-Dec-05 12:44 
GeneralRe: Can't get it to work PinmemberStumpy84215-Dec-05 15:47 
GeneralDotnetbar PinmemberNecklacer26-Oct-05 7:42 
GeneralRe: Dotnetbar PinmemberStumpy84226-Oct-05 16:02 
GeneralRe: Dotnetbar PinmemberNecklacer27-Oct-05 22:18 
GeneralWOW but How..... PinmemberNickJS18-Oct-05 15:35 
GeneralRe: WOW but How..... PinmemberStumpy84219-Oct-05 10:03 
GeneralRe: WOW but How..... PinmemberNickJS22-Oct-05 3:04 
GeneralRe: WOW but How..... PinmemberStumpy84224-Oct-05 12:18 
GeneralAdded divisions PinmemberGeoff Carlton22-Sep-05 16:56 
GeneralRe: Added divisions PinmemberStumpy84219-Oct-05 9:44 
GeneralRe: Added divisions Pinmemberklaus@gubbernet.com25-Sep-07 7:53 
GeneralLovely! PinmemberOmmina23-Aug-05 17:24 
GeneralRe: Lovely! PinmemberStumpy84219-Oct-05 9:49 
GeneralProgressbarText: My Suggestions Pinmemberapetras7518-Aug-05 2:15 
GeneralProgressbarText: My Suggestions (forgot something) Pinmemberapetras7518-Aug-05 2:47 
GeneralRe: ProgressbarText: My Suggestions (forgot something) PinmemberStumpy84220-Aug-05 20:08 
Generalnicely executed PinsussneuralSea87-Jul-05 12:59 
GeneralRe: nicely executed PinmemberStumpy84219-Aug-05 12:56 
GeneralLittle changes Pinmemberdbembibre1-Jun-05 0:49 
GeneralRe: Little changes PinmemberStumpy84221-Jun-05 17:32 
GeneralRe: Little changes Pinmembermaabd4-Jul-05 22:58 
GeneralRe: Little changes PinmemberStumpy8429-Jul-05 17:22 
GeneralRe: Little changes PinmemberLounge Lizard29-Dec-05 6:49 
GeneralRe: Little changes PinmemberTheBlueEyz13-Mar-06 16:34 
GeneralNice Progessbar but... Pinmemberrobprogger24-Feb-05 8:39 
GeneralRe: Nice Progessbar but... PinmemberStumpy84225-Feb-05 11:44 
GeneralSmooth progress bar PinmemberGer Rietman22-Feb-05 22:03 
GeneralRe: Smooth progress bar PinmemberStumpy84223-Feb-05 19:00 
GeneralRead the original article for more background PinmemberStumpy84219-Feb-05 15:58 

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.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150301.1 | Last Updated 28 Feb 2005
Article Copyright 2005 by Stumpy842
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid