Click here to Skip to main content
13,868,826 members
Click here to Skip to main content
Add your own
alternative version


66 bookmarked
Posted 19 Feb 2005

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

You may also be interested in...

Comments and Discussions

GeneralMy vote of 5 Pin
Member 964319729-Nov-12 12:54
memberMember 964319729-Nov-12 12:54 
QuestionWorks beautifully -- Thank you. Pin
Texas_MO26-Nov-12 8:31
memberTexas_MO26-Nov-12 8:31 
GeneralMy vote of 5 Pin
sboulstridge15-Nov-12 9:54
membersboulstridge15-Nov-12 9:54 
GeneralMy vote of 5 Pin
fixo1-Aug-10 20:07
memberfixo1-Aug-10 20:07 
GeneralVery nice article Pin
Sheikh Rahat Ali31-Jul-09 5:37
memberSheikh Rahat Ali31-Jul-09 5:37 
GeneralMarquee Style Pin
windwrd011-Aug-08 10:40
memberwindwrd011-Aug-08 10:40 
GeneralRefresh Problem Pin
John Maddox9-Aug-07 8:43
memberJohn Maddox9-Aug-07 8:43 
GeneralThanks Man!!! Pin
sspanogle16-Feb-07 6:34
membersspanogle16-Feb-07 6:34 
GeneralRe: Thanks Man!!! Pin
Stumpy84218-Feb-07 6:30
memberStumpy84218-Feb-07 6:30 
Generalplotting coordinates with vb application and saving it as dxf file. Pin
emmaddais22-Dec-06 3:31
memberemmaddais22-Dec-06 3:31 
GeneralGreat, but can't get IntelliSense to work Pin
wim.NET28-Jun-06 0:09
memberwim.NET28-Jun-06 0:09 
GeneralRe: Great, but can't get IntelliSense to work Pin
Stumpy84229-Jun-06 17:35
memberStumpy84229-Jun-06 17:35 
GeneralSettings not saving correctly. Pin
VTHoodlum14-Mar-06 4:20
memberVTHoodlum14-Mar-06 4:20 
GeneralRe: Settings not saving correctly. Pin
Patrick Etc.5-Apr-06 12:02
memberPatrick Etc.5-Apr-06 12:02 
GeneralCan't get it to work Pin
Dan Demp14-Dec-05 12:44
memberDan Demp14-Dec-05 12:44 
GeneralRe: Can't get it to work Pin
Stumpy84215-Dec-05 15:47
memberStumpy84215-Dec-05 15:47 
GeneralDotnetbar Pin
Necklacer26-Oct-05 7:42
memberNecklacer26-Oct-05 7:42 
GeneralRe: Dotnetbar Pin
Stumpy84226-Oct-05 16:02
memberStumpy84226-Oct-05 16:02 
GeneralRe: Dotnetbar Pin
Necklacer27-Oct-05 22:18
memberNecklacer27-Oct-05 22:18 
GeneralWOW but How..... Pin
NickJS18-Oct-05 15:35
memberNickJS18-Oct-05 15:35 
GeneralRe: WOW but How..... Pin
Stumpy84219-Oct-05 10:03
memberStumpy84219-Oct-05 10:03 
GeneralRe: WOW but How..... Pin
NickJS22-Oct-05 3:04
memberNickJS22-Oct-05 3:04 
GeneralRe: WOW but How..... Pin
Stumpy84224-Oct-05 12:18
memberStumpy84224-Oct-05 12:18 
GeneralAdded divisions Pin
Geoff Carlton22-Sep-05 16:56
memberGeoff Carlton22-Sep-05 16:56 
GeneralRe: Added divisions Pin
Stumpy84219-Oct-05 9:44
memberStumpy84219-Oct-05 9:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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 | Cookies | Terms of Use | Mobile
Web06 | 2.8.190214.1 | Last Updated 28 Feb 2005
Article Copyright 2005 by Stumpy842
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid