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

Custom ProgressBar Control

By , 8 Jun 2011
 
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.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionHow to put in visual basicmemberMember 992891720 Mar '13 - 16:25 
How can i implement this on vb do i put it in the toolbox?(how)
 
or do i make a new project add this in it and call on it?
AnswerRe: How to put in visual basicmemberJeff Reith6 Apr '13 - 12:20 
I have this question, too. It all comes in as a complete project... how do I add one of these awesome progress bars to my existing project? I was able to put the progressbar project in my projects folder, compile and run it, but I just want to add a toolbar to my existing project. I assume that this is what Member 9928917 is asking?
GeneralRe: How to put in visual basicmemberSSDiver21126 Apr '13 - 13:07 
Look up adding dll or custom control to the toolbox for more detail.
 
Basically:
Compile the project and the dll will be in the bin folder.
Right Click in the Toolbox and select 'Choose Items...' and when the dialog box opens click Browse to navigate to where the dll is (the bin folder or your dll folder if you moved a copy somewhere).

or

Open Windows Explorer and drag the dll and drop it in the Toolbox.

SSDiver2112
AnswerRe: How to put in visual basicmemberSSDiver21126 Apr '13 - 13:08 
Look up adding dll or custom control to the toolbox for more detail.
 
Basically:
Compile the project and the dll will be in the bin folder.
Right Click in the Toolbox and select 'Choose Items...' and when the dialog box opens click Browse to navigate to where the dll is (the bin folder or your dll folder if you moved a copy somewhere).

or

Open Windows Explorer and drag the dll and drop it in the Toolbox.

SSDiver2112
QuestionPlease i need helpmemberSamjoke6 Feb '13 - 17:47 
Please help me !! ive managed to add the dll to my toolbar and when i try to build my solution i get errors just like ProgBar project wouldnt exist(ProgBar is referenced in my project and my project is set to depend on ProgBar)
Thank You!
AnswerRe: Please i need helpmemberSSDiver21126 Feb '13 - 17:57 
Samjoke,
You need to give more information (detail) about what problem you are having like what errors your are getting and at what point are you getting them.
 
SSDiver2112
GeneralRe: Please i need helpmemberSamjoke7 Feb '13 - 4:48 
Thank you for quick response , its fixed Ive retargeted my project and now it works like charm
Thank you for sharing ......Thumbs Up | :thumbsup:
GeneralMy vote of 5memberPolinia11 Jan '13 - 7:07 
A like this!
Bugi have this errors in the designer mode in visual studio 2012memberspiritdead23 Aug '12 - 16:06 
en System.ComponentModel.ReflectPropertyDescriptor.SetValue(Object component, Object value)
en System.ComponentModel.ReflectPropertyDescriptor.ResetValue(Object component)
en System.ComponentModel.Design.Serialization.CodeDomSerializer.ResetBrowsableProperties(Object instance)
en System.ComponentModel.Design.Serialization.CodeDomSerializer.Deserialize(IDesignerSerializationManager manager, Object codeObject)
en System.Windows.Forms.Design.ControlCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, Object codeObject)
en System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.DeserializeName(IDesignerSerializationManager manager, String name, CodeStatementCollection statements
i need help
GeneralRe: i have this errors in the designer mode in visual studio 2012memberspiritdead26 Aug '12 - 9:31 
in this link http://www.mediafire.com/?6lf5pbh40ae0wma
i upload the new fix for the proyect now work in VS2010 and VS2012 THX MSDN for the help
the author of the fix = softjaen
QuestionThanksmemberJose David Campo10 Jul '12 - 7:26 
Excelect Job!!
QuestionNice Control!membersoupman614 Jan '12 - 8:12 
I long for the days when I could just click-on my TI-994A, see the prompt "TI-Basic Ready", and start having fun. (Remember Parsec?)
 
This control is very sweet.
 
I'm wondering what it would take to get it to compile using the .Net 4.0 Client Profile?
 
Regards,
 
Chris
AnswerRe: Nice Control!memberSSDiver21124 Jan '12 - 13:04 
Hi Chris,
I just found this recently: Classic99 Emulator[^]
 
It really brings back the memories. In also OCR'd some old programs I wrote back in the day and they Worked! It is really cool seeing them working again after so many years.
 
I am not sure what it will take to get it working with the ClientProfile I may look when I have some time.
 
SSDiver2112
GeneralRe: Nice Control!membersoupman615 Jan '12 - 8:03 
Wow, I could really lose myself in that for a while (heh)
 
Thanks for the link.
 
Chris
QuestionHow do I compilemembertreaverh24 Nov '11 - 17:42 
How to compile it?
AnswerRe: How do I compilememberSSDiver211226 Nov '11 - 17:04 
Just choose Build Solution.
GeneralImpressivememberCIDev8 Jun '11 - 5:49 
I have a fondness for progress controls, perhaps because so many programmers don't bother to add them. You have a clearly written article and a very impressive & flexible progress control. You get a 5 from me.
Just because the code works, it doesn't mean that it is good code.

GeneralCan't find the .dllmembermikehilton11 Nov '09 - 7:31 
Shouldn't I be seeing a .dll file in the extracted files?
 
Thanks. Looks like a great control.
GeneralRe: Can't find the .dllmembermikehilton11 Nov '09 - 8:12 
Figured it out. Thanks. It is a great control!!
GeneralRe: Can't find the .dll [modified]memberOnur Guzel27 Apr '11 - 0:04 
I Can't find it neither, i hate projects that expects me to compile the project and produce the actual dll.
 
Plus, before rebuilding the project (when first opened vbproj of test form) i got 105 warnings about declerations and the actual form is not visible in designer using VS 2005.
 
When you just alone set Value property, nothing happens, it seems "Timer" was used in sample project.

modified on Wednesday, April 27, 2011 6:15 AM

GeneralRe: Can't find the .dllmemberSSDiver211227 Apr '11 - 2:02 
I am sorry for the trouble you are having, but every project must be compiled to create the dll's.
 
As stated in the Submission Guidelines for Code Project Articles:
 
"Sample Project:It is recommended that you also include a sample project. When creating a zip file for the sample project, please do not include either the Debug or the Release directories. They simply inflate the size of the ZIP file. Also, do not include the *.clw, *.ncb, *.opt and other such files that are automatically recreated."
 
Because of this, the project will not have sufficient information to view forms and such until it is rebuilt and all the supporting files are created.
 
SSDiver2112
GeneralInstalling the control in VBmemberdedawson402420 Apr '09 - 9:30 
Stupid question time. This control looks likes the answer I've been looking for; an easy way to do progress bars in Word 2003 VBA.

But, I'm still a bit confused. Looking in the zip, I see no ReadMe telling me how to get the control installed. I'd be ever so grateful if someone could enlighten me.
 
dedawson
GeneralRe: Installing the control in VBmemberSSDiver211220 Apr '09 - 10:15 
I'm not really sure how or even if you can. I would suggest doing a search for "add vb.net usercontrol to VBA" or something similar. For simplicity in VBA I have used two labels. One label has a transparent backcolor, border and text. A second label is layered behind the first. Adjust the width of this one to simulate the progress bar. lblBar.Width = currentValue * ((lblBarBack.Width - 2) / maximumValue) Another thing I have done is replace the Label lblBar with an Image control to use a bitmap as the Bar.
 
SSDiver2112
GeneralRe: Installing the control in VBmemberdedawson402420 Apr '09 - 10:53 
I was afraid of that. I'm guessing, that in the .net world, this control gets compiled and can then be employed as an ADDIN. Is there any possibility you might be able to provide such a module (.com, .dll, etc) that I could try loading as such? I only have the VBA that is resident in Office, with no means of doing a .net compile.
 
thanks in advance,
 
david
 
dedawson
GeneralGood controlmemberDonsw8 Feb '09 - 6:14 
Good control, Nice features. Well thought out.

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

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