Click here to Skip to main content
Licence 
First Posted 30 Jun 2004
Views 213,707
Bookmarked 54 times

C# Progress Bar Status Bar Panel

By | 30 Jun 2004 | Article
A reusable progress bar panel control for display inside the status bar.

Progress Bar In Use

Introduction

You can't just drop a progress bar control into a status bar panel, so I made this. This is actually the second time I've had to do this, so I got fed up and wanted to drop the code here so nobody would have to do it again.

Using the code

First thing to do is just drop a status bar on your form, and create a Panel or two. You can mess around with the panel settings afterwards, but the easiest thing to do is select Owner-Draw on the status bar panel that you want to be the progress bar from the very beginning.

// Change the type of the panel to StatusBarProgressPanel on your Form
private StatusBarProgressPanel progressPanel;

// Initialize the measurement values
progressPanel.StartPoint = 0;
progressPanel.EndPoint = 100;
progressPanel.StepSize = 1;
progressPanel.ProgressPosition = 0;

Of course, once you change the type, you can change the properties using the Visual Studio Designer by simply clicking the "..." button of the Panel's property when the status bar is selected in the form designer. I've included some handy category attributes for Visual Studio's nifty reflection logic to pick up.

Properties Dialog from Status Bar in Form Designer

// Sample usage:

// progress the bar by one "step"
progressPanel.Step();

// reset the progress bar to the initial state
progressPanel.Reset();

// start/stop an infinite animation thread for the bar
// this is useful when you don't know how long something
// is going to take, or if the progress is just unmeasurable
progressPanel.StartAnimation();
progressPanel.StopAnimation();

// By default the value of the percentage of progress is displayed
// setting the "ShowText" property to false disables it
progressPanel.ShowText = false;

You may also change the AnimationStyle of the control. This basically controls the way the indicator is filled and emptied. The default is ProgressDisplayStyle.Infinate which is a pulsating draw style. Much cooler graphics can be used, just modify the Parent_DrawItem method.

/// <summary>
/// Statusbar Progress Display Styles
/// </summary>
public enum ProgressDisplayStyle
{
    /// <summary>
    /// A continually moving animation
    /// </summary>
    Infinite,
    /// <summary>
    /// A progress bar that fills from left to right
    /// </summary>
    LeftToRight,
    /// <summary>
    /// A progress bar that fills from right to left
    /// </summary>
    RightToLeft,
    /// <summary>
    /// A progress bar that fills from bottom to top
    /// </summary>
    BottomToTop,
    /// <summary>
    /// A progress bar that fills from top to bottom
    /// </summary>
    TopToBottom
}

History

  • 7/1/2004 - Initial revision.

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

About the Author

steven_fusco



United States United States

Member



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
Questionnew PinmemberAslam Jarwar22:01 3 Mar '12  
GeneralMy vote of 1 Pinmemberch@ndr@ mouli23:31 4 Aug '11  
Generalanother stylish progress bar PinmemberRamesh Soni22:28 7 Jul '07  
GeneralNicely done PinmemberKevin Sanders13:00 25 Nov '05  
GeneralUpdating while working PinmemberRyanRushaConto14:50 10 Jul '05  
GeneralRe: Updating while working Pinmemberww_b0:05 8 Nov '06  
GeneralForcing Style=Owner-Draw PinsussMike Kiefer14:47 1 Jun '05  
GeneralprogressPosition update doesn't update the bar Pinmemberwinryan10:13 12 Mar '05  
GeneralThanks + small bug fix . PinsussAnonymous7:46 18 Jul '05  
GeneralRe: Thanks + small bug fix . [modified] Pinmember__alias6:19 13 Sep '06  
GeneralDouble Buffer Progress PinmemberCoreyRIT10:47 8 Dec '04  
GeneralRe: Double Buffer Progress Pinsussjohn hatton1:15 22 Dec '04  
GeneralPanel turns white PinsussPhillip Ring11:09 2 Aug '04  
QuestionHow to use your 'StatusBarProgressPanel' in design mode directly? Pinmemberw1424314:53 11 Jul '04  
AnswerRe: How to use your 'StatusBarProgressPanel' in design mode directly? Pinmembersteven_fusco4:42 12 Jul '04  
GeneralRe: How to use your 'StatusBarProgressPanel' in design mode directly? PinmemberChristian Wikander21:54 9 Aug '04  
GeneralRe: How to use your 'StatusBarProgressPanel' in design mode directly? Pinmemberrsil21:10 5 Oct '04  
GeneralRe: How to use your 'StatusBarProgressPanel' in design mode directly? Pinmembermkiefer15:04 1 Jun '05  
GeneralGreat work Pinmemberwindcbf21:24 6 Jul '04  
GeneralFinally PinmemberMr. Rogers11:41 6 Jul '04  

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
Web01 | 2.5.120517.1 | Last Updated 1 Jul 2004
Article Copyright 2004 by steven_fusco
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid