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:
...
using ColorProgressBar;
namespace WindowsApplication3
{
public class Form1 : System.Windows.Forms.Form
{
...
private ColorProgressBar.ColorProgressBar progress;
...
public Form1()
{
InitializeComponent();
#region Add a Alan Zhao Color ProgressBar
this.progress = new ColorProgressBar.ColorProgressBar();
this.progress.Size = new Size(200, 20);
this.progress.Location = new Point(200, 2);
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;
this.statusBar1.Controls.Add(this.progress);
this.progress.Show();
#endregion
this.button1_Click(this, EventArgs.Empty);
}
...
}
}
There are four important steps:
- Take special attention about the dimensions of your status bar and make your progress bar to fit in the statusbar:
this.progress.Size = new Size(200, 20);
- 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:
this.progress.Location = new Point(200, 2);
- Add it to your status bar:
this.statusBar1.Controls.Add(this.progress);
- Finally show it:
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.