Created
July 25, 2016 17:01
-
-
Save drmcarvalho/21495978a186c00c44c7782397e88cd2 to your computer and use it in GitHub Desktop.
Exemplo ProgressBar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Threading; | |
using System.Windows.Forms; | |
namespace ProgressBarExemplo | |
{ | |
public partial class Form1 : Form | |
{ | |
public Form1() | |
{ | |
InitializeComponent(); | |
} | |
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) | |
{ | |
for (int i = 1; i <= 100; i++) | |
{ | |
Thread.Sleep(100); | |
backgroundWorker1.ReportProgress(i); | |
} | |
} | |
private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e) | |
{ | |
progressBar1.Value = e.ProgressPercentage; | |
Text = e.ProgressPercentage.ToString(); | |
if (progressBar1.Value >= 1 && progressBar1.Value <= 50) | |
{ | |
label1.Text = "Installing Virus"; | |
} | |
else if (progressBar1.Value > 50 && progressBar1.Value <= 100) | |
{ | |
label1.Text = "Downloading Virus"; | |
} | |
} | |
private void button1_Click(object sender, EventArgs e) | |
{ | |
backgroundWorker1.RunWorkerAsync(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment