Click here to Skip to main content
11,505,005 members (69,399 online)
Click here to Skip to main content

Color ProgressBar

, 30 Apr 2004 191.5K 8.1K 60
Rate this:
Please Sign up or sign in to vote.
An attractive and fancier ProgressBar.

Introduction

This is a fairly simple Progress Bar control inherited from Windows.Forms.Control. The reason I reinvented this "wheel" is I don't like the looks of traditional ProgressBar provided in VS.NET. My ColorProgressBar looks more attractive and fancier, yet keeps the functionalities of old ProgressBar. I hope I will get some genuine comments or suggestion from you.

Complete source code can be downloaded from the link above.

Control Properties

  • BarColor

    The primary color of ColorProgressBar.

  • BorderColor

    The border color of ColorProgressBar.

  • FillStyle

    Bar styles, "Solid" or "Dashed".

  • Maximum

    The maximum value of ColorProgressBar.

  • Minimum

    The minimum value or the initial value of ColorProgressBar.

  • Value

    The current value of ColorProgressBar.

  • Step

    The value of each increment or decrement when you call methods PerformStep() and PerformStepBack().

Control Methods

  • PerformStep()

    Call the PerformStep() method to increase the value set in the Step property.

  • PerformStepBack()

    Call the PerformStepBack() method to decrease the value set in the Step property.

  • Increment(int value)

    Call the Increment() method to increase the integer value you specify.

  • Decrement(int value)

    Call the Decrement() method to decrease the integer value you specify.

Example

- See snapshot above

A timer is used to fake progress.

//
// Control declarations
//
this.cpb1 = new ColorProgressBar.ColorProgressBar();
this.cpb2 = new ColorProgressBar.ColorProgressBar();
this.cpb3 = new ColorProgressBar.ColorProgressBar();
this.cpb4 = new ColorProgressBar.ColorProgressBar();
this.cpb5 = new ColorProgressBar.ColorProgressBar();
this.cpb6 = new ColorProgressBar.ColorProgressBar();
this.timer1 = new System.Windows.Forms.Timer(this.components);


// 
// cpb1
// 
this.cpb1.BarColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), 
                     ((System.Byte)(128)), ((System.Byte)(128)));
this.cpb1.BorderColor = System.Drawing.Color.Black;
this.cpb1.FillStyle = ColorProgressBar.ColorProgressBar.FillStyles.Dashed;
this.cpb1.Location = new System.Drawing.Point(56, 48);
this.cpb1.Maximum = 100;
this.cpb1.Minimum = 0;
this.cpb1.Name = "cpb1";
this.cpb1.Size = new System.Drawing.Size(150, 15);
this.cpb1.Step = 10;
this.cpb1.TabIndex = 0;
this.cpb1.Value = 0;
// 
// cpb2
// 
this.cpb2.BarColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), 
                     ((System.Byte)(255)), ((System.Byte)(128)));
this.cpb2.BorderColor = System.Drawing.Color.Black;
this.cpb2.FillStyle = ColorProgressBar.ColorProgressBar.FillStyles.Solid;
this.cpb2.Location = new System.Drawing.Point(56, 72);
this.cpb2.Maximum = 100;
this.cpb2.Minimum = 0;
this.cpb2.Name = "cpb2";
this.cpb2.Size = new System.Drawing.Size(150, 15);
this.cpb2.Step = 10;
this.cpb2.TabIndex = 1;
this.cpb2.Value = 100;
// 
// cpb3
// 
this.cpb3.BarColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), 
                     ((System.Byte)(255)), ((System.Byte)(128)));
this.cpb3.BorderColor = System.Drawing.Color.Black;
this.cpb3.FillStyle = ColorProgressBar.ColorProgressBar.FillStyles.Dashed;
this.cpb3.Location = new System.Drawing.Point(56, 104);
this.cpb3.Maximum = 100;
this.cpb3.Minimum = 0;
this.cpb3.Name = "cpb3";
this.cpb3.Size = new System.Drawing.Size(192, 24);
this.cpb3.Step = 10;
this.cpb3.TabIndex = 2;
this.cpb3.Value = 0;
// 
// cpb4
// 
this.cpb4.BarColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), 
                     ((System.Byte)(255)), ((System.Byte)(255)));
this.cpb4.BorderColor = System.Drawing.Color.Black;
this.cpb4.FillStyle = ColorProgressBar.ColorProgressBar.FillStyles.Solid;
this.cpb4.Location = new System.Drawing.Point(56, 144);
this.cpb4.Maximum = 100;
this.cpb4.Minimum = 0;
this.cpb4.Name = "cpb4";
this.cpb4.Size = new System.Drawing.Size(192, 24);
this.cpb4.Step = 10;
this.cpb4.TabIndex = 3;
this.cpb4.Value = 100;
// 
// cpb5
// 
this.cpb5.BarColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), 
                     ((System.Byte)(128)), ((System.Byte)(255)));
this.cpb5.BorderColor = System.Drawing.Color.Black;
this.cpb5.FillStyle = ColorProgressBar.ColorProgressBar.FillStyles.Solid;
this.cpb5.Location = new System.Drawing.Point(56, 184);
this.cpb5.Maximum = 100;
this.cpb5.Minimum = 0;
this.cpb5.Name = "cpb5";
this.cpb5.Size = new System.Drawing.Size(272, 32);
this.cpb5.Step = 10;
this.cpb5.TabIndex = 4;
this.cpb5.Value = 0;
// 
// cpb6
// 
this.cpb6.BarColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), 
                     ((System.Byte)(128)), ((System.Byte)(0)));
this.cpb6.BorderColor = System.Drawing.Color.Black;
this.cpb6.FillStyle = ColorProgressBar.ColorProgressBar.FillStyles.Dashed;
this.cpb6.Location = new System.Drawing.Point(56, 232);
this.cpb6.Maximum = 100;
this.cpb6.Minimum = 0;
this.cpb6.Name = "cpb6";
this.cpb6.Size = new System.Drawing.Size(272, 32);
this.cpb6.Step = 10;
this.cpb6.TabIndex = 5;
this.cpb6.Value = 100;
// 
// timer1
// 
this.timer1.Enabled = true;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// Actual manipulation by timer1
//
private void timer1_Tick(object sender, System.EventArgs e)
{
    //
    // All values are reset at the end to have endless loop
    //
    cpb1.PerformStep();
    if (cpb1.Value == cpb1.Maximum)
        cpb1.Value = cpb1.Minimum;

    cpb2.PerformStepBack();
    if (cpb2.Value == cpb2.Minimum)
        cpb2.Value = cpb2.Maximum;

    cpb3.Increment(1);
    if (cpb3.Value == cpb3.Maximum)
        cpb3.Value = cpb3.Minimum;

    cpb4.Decrement(1);
    if (cpb4.Value == cpb4.Minimum)
        cpb4.Value = cpb4.Maximum;

    cpb5.Increment(1);
    if (cpb5.Value == cpb5.Maximum)
        cpb5.Value = cpb5.Minimum;

    cpb6.Decrement(1);
    if (cpb6.Value == cpb6.Minimum)
        cpb6.Value = cpb6.Maximum;
}

Missing Features

  • Percentage indicator.

Contributions

Using the Control

Adding ColorProgressBar control to Windows Form Toolbox

  1. Right-click the Windows Form Toolbox and choose Customize Toolbox... from the shortcut menu. The Customize Toolbox dialog box opens.
  2. Choose the .NET Framework Components tab and click Browse. Browse to the ColorProgressBar\bin\Release or \debug folder and select ColorProgressBar.dll. ColorProgressBar appears in the list of components in the Customize Toolbox dialog box.
  3. Check the box next to ColorProgressBar and Select OK. The ColorProgressBar is now added to the tab of the Windows ToolBox.

My Other Control Project

Feedbacks

Please vote for this article.

And email me or leave your messages if you have:

  • bug reports
  • code improvements
  • any comments or suggestions.

License

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

Share

About the Author

Alan Zhao
Web Developer www.LightspeedSigns.com
United States United States
Hi, my name is Alan Zhao. I live in Glens Falls, NY. Say hi to me if you see me one day.

also visit me at www.LinkGone.com - Make your long URLs easy to read, remember and reuse.

Comments and Discussions

 
QuestionLicense Terms - CPOL ? Pin
dbhatt7911-Mar-15 6:17
memberdbhatt7911-Mar-15 6:17 
QuestionLicense Type Used Pin
dbhatt7923-Feb-15 6:53
memberdbhatt7923-Feb-15 6:53 
QuestionThank you Pin
SrgjanX17-Feb-15 8:17
memberSrgjanX17-Feb-15 8:17 
Questiongood job Pin
Member 111692202-Nov-14 14:15
memberMember 111692202-Nov-14 14:15 
GeneralGood Job Alan Zhao. Pin
Nipuna Sandas5-Aug-14 23:58
memberNipuna Sandas5-Aug-14 23:58 
QuestionMany thanks Pin
David W. Wolfe12-Sep-13 23:34
memberDavid W. Wolfe12-Sep-13 23:34 
GeneralMy vote of 4 Pin
dan30085-May-13 5:54
memberdan30085-May-13 5:54 
GeneralMy vote of 5 Pin
Afaan Bilal3-Jan-13 6:14
memberAfaan Bilal3-Jan-13 6:14 
QuestionGreat and nice job! how can use in WPF? Pin
pablomartin28-Aug-12 23:32
memberpablomartin28-Aug-12 23:32 
GeneralMy vote of 5 Pin
abdul_khader2-May-12 5:28
memberabdul_khader2-May-12 5:28 
Generalrequesting agreement Pin
giova8-Nov-09 2:26
membergiova8-Nov-09 2:26 
GeneralRe: requesting agreement Pin
giova8-Nov-09 7:58
membergiova8-Nov-09 7:58 
Well my job is allmost over; just few improvement to add, also the Shape property to implement.

here the current result

On this picture, you see :

1st progressbar : simply with default properties values.

2nd progressbar : with properties set so the progressbar appareance is close of the .NET progressbar

3rd progressbar : with DisplayPercent property set to false, and using ValueChanged event to customize displayed text; also i've set Font to bold, and ForeColor to white.

4th & 5th progressbars : with TextAlign set to left (with margin.left property set to 15); 2nd one with text align set to Right

Last progressbar is a fake, because often people asks how to do a K2000 effet, i simply used the .NET progressbar, and set its style to K2000 Wink | ;)

Many other features and improvement into my class, described with comments (events, properties added, minor bugfixes,and so on)

Just awaiting agreement to publish...
GeneralThanks Pin
rushsky27-Oct-09 21:11
memberrushsky27-Oct-09 21:11 
GeneralMy vote of 2 Pin
Chizik4-May-09 21:00
memberChizik4-May-09 21:00 
GeneralI'm new and I'd like to use this but I don't where to put everything. Pin
DFlat4Now2-Oct-08 10:24
memberDFlat4Now2-Oct-08 10:24 
GeneralMarquee Pin
UltraWhack31-Mar-08 10:20
memberUltraWhack31-Mar-08 10:20 
GeneralC sharp Pin
nayyumaung16-Jan-07 20:11
membernayyumaung16-Jan-07 20:11 
GeneralExcellent Pin
jlgbzh13-Jun-05 1:44
memberjlgbzh13-Jun-05 1:44 
GeneralInvalidate() method doesn't update always Pin
rudy.net28-May-05 19:52
memberrudy.net28-May-05 19:52 
GeneralRe: Invalidate() method doesn't update always Pin
eliakaris8-Jun-05 3:39
membereliakaris8-Jun-05 3:39 
GeneralEnhancement of the project Pin
DDISoft23-Mar-05 22:04
memberDDISoft23-Mar-05 22:04 
GeneralRe: Enhancement of the project Pin
Alan Zhao27-Mar-05 10:09
memberAlan Zhao27-Mar-05 10:09 
GeneralRe: Enhancement of the project Pin
DDISoft31-Mar-05 3:07
memberDDISoft31-Mar-05 3:07 
GeneralVisualStyle Pin
vandergeld23-Feb-05 23:42
membervandergeld23-Feb-05 23:42 
GeneralThank You. Pin
Karv2-Feb-05 10:30
memberKarv2-Feb-05 10:30 
QuestionHow to clear progress bar Pin
Anonymous28-Jul-04 14:30
sussAnonymous28-Jul-04 14:30 
AnswerRe: How to clear progress bar Pin
rlnoble9-Oct-04 21:01
memberrlnoble9-Oct-04 21:01 
GeneralProgress indicator Pin
SeveredCross13-Jun-04 7:01
memberSeveredCross13-Jun-04 7:01 
GeneralCool Control Pin
<a href='http://www.coderforrent.com'>coderforrent2-May-04 16:27
membercoderforrent2-May-04 16:27 
GeneralSPAMMER Pin
abhadresh2-May-04 16:30
memberabhadresh2-May-04 16:30 
GeneralSuggestion Pin
leppie1-May-04 9:37
memberleppie1-May-04 9:37 
GeneralRe: Suggestion Pin
Alan Zhao1-May-04 13:02
memberAlan Zhao1-May-04 13:02 
GeneralRe: Suggestion Pin
mav.northwind1-May-04 22:48
membermav.northwind1-May-04 22:48 
GeneralRe: Suggestion Pin
Alan Zhao2-May-04 5:46
memberAlan Zhao2-May-04 5:46 
GeneralRe: Suggestion Pin
mav.northwind2-May-04 6:32
membermav.northwind2-May-04 6:32 
GeneralRe: Suggestion Pin
Alan Zhao3-May-04 18:42
memberAlan Zhao3-May-04 18:42 
GeneralRe: Suggestion Pin
mav.northwind4-May-04 8:18
membermav.northwind4-May-04 8:18 
GeneralRe: Suggestion Pin
Alan Zhao4-May-04 9:52
memberAlan Zhao4-May-04 9:52 
GeneralRe: Suggestion Pin
mav.northwind4-May-04 19:51
membermav.northwind4-May-04 19:51 

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
Web03 | 2.8.150520.1 | Last Updated 1 May 2004
Article Copyright 2004 by Alan Zhao
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid