C# Developers' Journal (original) (raw)
8:24p
ProgressBar Status I'm still pretty new to C#. How do I implement the following to work correctly (the status is updated)? I want to show an accurate percentage of the progress bar. Ignore the extra figures after the decimal point.
private void button1_Click(object sender, EventArgs e)
{
timer1.Start();
button1.Enabled = false;
}
private void timer1_Tick(object sender, EventArgs e)
{
if (progressBar1.Value == progressBar1.Maximum)
{
timer1.Stop();
button1.Enabled = true;
label3.Text = "100%";
return;
}
progressBar1.PerformStep();
double x = (progressBar1.Value/progressBar1.Maximum) * 100.0;
label3.Text = String.Format("{0}%", x);
}
Thanks!