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

C# Progress Bar Status Bar Panel

, 30 Jun 2004
Rate this:
Please Sign up or sign in to vote.
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.

/// <span class="code-SummaryComment"><summary>
</span>
/// Statusbar Progress Display Styles
/// <span class="code-SummaryComment"></summary>
</span>
public enum ProgressDisplayStyle
{
    /// <span class="code-SummaryComment"><summary>
</span>
    /// A continually moving animation
    /// <span class="code-SummaryComment"></summary>
</span>
    Infinite,
    /// <span class="code-SummaryComment"><summary>
</span>
    /// A progress bar that fills from left to right
    /// <span class="code-SummaryComment"></summary>
</span>
    LeftToRight,
    /// <span class="code-SummaryComment"><summary>
</span>
    /// A progress bar that fills from right to left
    /// <span class="code-SummaryComment"></summary>
</span>
    RightToLeft,
    /// <span class="code-SummaryComment"><summary>
</span>
    /// A progress bar that fills from bottom to top
    /// <span class="code-SummaryComment"></summary>
</span>
    BottomToTop,
    /// <span class="code-SummaryComment"><summary>
</span>
    /// A progress bar that fills from top to bottom
    /// <span class="code-SummaryComment"></summary>
</span>
    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

Share

About the Author

steven_fusco

United States United States
No Biography provided

Comments and Discussions

 
GeneralMy vote of 4 PinmemberBurak Tunçbilek18-Jun-12 11:23 
Questionnew PinmemberAslam Jarwar3-Mar-12 23:01 
GeneralMy vote of 1 Pinmemberch@ndr@ mouli5-Aug-11 0:31 
Generalanother stylish progress bar PinmemberRamesh Soni7-Jul-07 23:28 
GeneralNicely done PinmemberKevin Sanders25-Nov-05 14:00 
GeneralUpdating while working PinmemberRyanRushaConto10-Jul-05 15:50 
GeneralRe: Updating while working Pinmemberww_b8-Nov-06 1:05 
GeneralForcing Style=Owner-Draw PinsussMike Kiefer1-Jun-05 15:47 
GeneralprogressPosition update doesn't update the bar Pinmemberwinryan12-Mar-05 11:13 
GeneralThanks + small bug fix . PinsussAnonymous18-Jul-05 8:46 
GeneralRe: Thanks + small bug fix . [modified] Pinmember__alias13-Sep-06 7:19 
GeneralDouble Buffer Progress PinmemberCoreyRIT8-Dec-04 11:47 
GeneralRe: Double Buffer Progress Pinsussjohn hatton22-Dec-04 2:15 
GeneralPanel turns white PinsussPhillip Ring2-Aug-04 12:09 
QuestionHow to use your 'StatusBarProgressPanel' in design mode directly? Pinmemberw1424311-Jul-04 15:53 
AnswerRe: How to use your 'StatusBarProgressPanel' in design mode directly? Pinmembersteven_fusco12-Jul-04 5:42 
GeneralRe: How to use your 'StatusBarProgressPanel' in design mode directly? PinmemberChristian Wikander9-Aug-04 22:54 
GeneralRe: How to use your 'StatusBarProgressPanel' in design mode directly? Pinmemberrsil5-Oct-04 22:10 
GeneralRe: How to use your 'StatusBarProgressPanel' in design mode directly? Pinmembermkiefer1-Jun-05 16:04 
GeneralGreat work Pinmemberwindcbf6-Jul-04 22:24 
GeneralFinally PinmemberMr. Rogers6-Jul-04 12:41 

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
Web02 | 2.8.141223.1 | Last Updated 1 Jul 2004
Article Copyright 2004 by steven_fusco
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid