Hi NurveTech;
Place a Timer control on to the form and set its Interval property to 1000 and its Enable property to false which should be the default. The when you need to start the progress bar turn on the timer with a statement like this.
timer1.Enabled = true;
This event will be called once a second.
private void timer1_Tick(object sender, EventArgs e)
{
// Update progress bar
progressBar1.Increment(1);
if (progressBar1.Value == progressBar1.Maximum)
{
progressBar1.Value = 0;
}
}
// The to turn off the progress bar stop the timer like this.
timer1.Enabled = false;
Now be aware that this code will not work well if you are doing a long process if the process does not do a Application.DoEvents(); or the process is running in a separate thread.
Fernando
Main Topics
Browse All Topics





by: JimBrandleyPosted on 2007-08-21 at 13:56:30ID: 19741482
Do you want to display an elapsed time? Say the time spent on the activity driving the progress bar so far?
Jim