How to use the progressbar in windows forms

No.of Views1234
Bookmarked0 times
Downloads 
Votes0
By  NikhilJohari   On  24 Apr 2010 20:04:57
Tag : CSharp , Progress Controls
How to use the progressbar in windows forms
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 

Introduction

A ProgressBar control is used to display the progress of some activity. The attached application creates a ProgressBar and shows the server activity. The project is developed using C#, Windows Forms, and Visual Studio 2005.


The UI of the application looks like following.

 

Image Loading

 

 

 

The source code is listed below. As you can see below, I add a timer control to the form and on the timer tick event handler, I increament the value of the progressbar. Download the attached project for more details.

namespace Progress_Bar
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
// Call the function of tick event of the timer:_...
// Set the timer Intervel at 60:_
// Set the timer enabled "True" by the timer properties:_
private void timer1_Tick(object sender, EventArgs e)
{
fn_prbar_();
}
//Create the function for progress bar:_
public void fn_prbar_()
{
progressBar1.Increment(1);
label1.Text = "Connecting to server_  "  + progressBar1.Value.ToString() +  "%";
if (progressBar1.Value == progressBar1.Maximum)
{
timer1.Stop();
MessageBox.Show("Server has been connected");
this.Close();
timer1.Stop();
}
}
}
}

 

That's all

 
Sign Up to vote for this article
 
About Author
 
NikhilJohari
Occupation-
Company-
Member Type-Senior
Location-India
Joined date-15 Aug 2009
Home Page-http://fast-get.com
Blog Page-http://dotnetask.blog.co.in
 
 
Other popularSectionarticles
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top