Click here to Skip to main content
15,879,096 members
Articles / Programming Languages / C#
Article

StatusColorProgressbar

Rate me:
Please Sign up or sign in to vote.
2.50/5 (11 votes)
9 Mar 20051 min read 44.4K   407   23   2
An article about adding Alan Zhao's Color Progressbar to your statusbar.

Sample Image

Introduction

This article shows how to easily add Colour Progress bar, by Alan Zhao, to your Windows Form status bar. It's quite simple to do it, of course our friend Alan did a very good job, now we have to use it...

Using the code

See how to create and use Colour Progress bar on Alan Zhao's article.

Now I'm only going to explain how to add a progress bar to your status bar. First, you have to have a Windows Form with a status bar and then create you progress bar. Take a look at the code below:

C#
...
using ColorProgressBar;

namespace WindowsApplication3
{
    /// 
    /// Summary description for Form1.
    /// 
    public class Form1 : System.Windows.Forms.Form
    {
        ...
        private ColorProgressBar.ColorProgressBar progress;
        ...
        public Form1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor
            // code after InitializeComponent call
            //

            #region Add a Alan Zhao Color ProgressBar
            // progress bar declaration
            this.progress = new ColorProgressBar.ColorProgressBar();
            // lets set progress bar size
            this.progress.Size = new Size(200, 20);
            // lets set progress location
            // to (statusBarPnel1.Width + statusBarPanel2.Width)
            this.progress.Location = new Point(200, 2);

            //Lets set some proprieties of progress bar
            // Bar color
            this.progress.BarColor = Color.AliceBlue;
            this.progress.Maximum = 100;
            this.progress.Minimum = 0;
            this.progress.Step = 1;
            this.progress.BorderColor = Color.Gray;
            this.progress.Value = 0;
            this.progress.FillStyle = 
               ColorProgressBar.ColorProgressBar.FillStyles.Solid;

            // Add progress bar to statusBar
            this.statusBar1.Controls.Add(this.progress);
            // show progress bar
            this.progress.Show();
            #endregion

            // reset counter
            this.button1_Click(this, EventArgs.Empty);

        }

        ...
    }
}

There are four important steps:

  1. Take special attention about the dimensions of your status bar and make your progress bar to fit in the statusbar:
    C#
    this.progress.Size = new Size(200, 20);
  2. Once your progress bar fits into your status bar, make it appear on the right place by locating it into your status bar, like this code exemplifies:
    C#
    this.progress.Location = new Point(200, 2);
  3. Add it to your status bar:
    C#
    this.statusBar1.Controls.Add(this.progress);
  4. Finally show it:
    C#
    this.progress.Show();

Isn't it simple?! Sure it is. Now you have just to use your StatusColorProgressbar.

Points of Interest

I was searching for a thing like this to use on my "projecto de bacharelato" - PICrega. I have read many articles on "The Code Project”, but none of them was like what I wanted. Then, I searched and researched and I made one like I wanted. That makes me feel so good, so nice! paparara_ra.

The thing is: you might add other controls to you status bar using: statusbar.Controls.Add(your control).

Thanks

I'd like to thank all "The Code Project" members, and personally Alan Zhao who made a very nice Colour ProgressBar.

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


Written By
Engineer Freelancer
Portugal Portugal
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Newsthank you Pin
matafill++c23-Jun-11 8:54
matafill++c23-Jun-11 8:54 
GeneralThank you ..... Pin
Jack297-May-08 20:04
Jack297-May-08 20:04 

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.