articles

Home / DeveloperSection / Articles / Using Progress Bar Status Bar Timer Control in CSharp .NET

Using Progress Bar Status Bar Timer Control in CSharp .NET

Anonymous User13217 30-Jul-2010

Here I’m going to demonstrate how to use Progress Bar, status Bar and Timer controls in C#.Net


Using Progress Bar Status Bar Timer Control in CSharp .NET 

Example

//creating method getTime() to get current system time.
string getTime()
        {
            string time = "";
            time = DateTime.Now.Hour.ToString() + ":" + DateTime.Now.Minute.ToString() + ":" + DateTime.Now.Second.ToString();
            return time;
        }
 
//executing progress bar at button click event.
        privatevoid btnLoad_Click(object sender, EventArgs e)
        {           
            for (int i = progressBar1.Minimum; i <= progressBar1.Maximum; i++)
            {
//displaying ‘loading...’ in status bar
                statLabel.Text = "loading...";
                progressBar1.Increment(1);
            }           
 
            statLabel.Text = "Loading Complete";
        }
 
        privatevoid Form2_Load(object sender, EventArgs e)
        {
//setting timer interval to 1sec
            timer1.Interval = 1000;
//enabling timer
            timer1.Enabled = true;
//seting minimun limit of progress bar
            progressBar1.Minimum = 1;
//seeting maximum limit of progress bar
            progressBar1.Maximum = 1000000;
//setting step
            progressBar1.Step = 1;           
//displating current time in label
            label1.Text = getTime();
        }
 
//updating label text every sec. to display current time at timer tick event.
        privatevoid timer1_Tick(object sender, EventArgs e)
        {           
            label1.Text = getTime();
        }


Using Progress Bar Status Bar Timer Control in CSharp .NET


Updated 11-Jul-2020
I am a content writter !

Leave Comment

Comments

Liked By