if (progressBar1.Value == 1) { progressLabel.Text = "1%"; }
if (progressBar1.Value == 10) { progressLabel.Text = "10%"; }
if (progressBar1.Value == 20) { progressLabel.Text = "20%"; }
if (progressBar1.Value == 30) { progressLabel.Text = "30%"; }
if (progressBar1.Value == 40) { progressLabel.Text = "40%"; }
if (progressBar1.Value == 50) { progressLabel.Text = "50%"; }
if (progressBar1.Value == 60) { progressLabel.Text = "60%"; }
if (progressBar1.Value == 70) { progressLabel.Text = "70%"; }
if (progressBar1.Value == 80) { progressLabel.Text = "80%"; }
if (progressBar1.Value == 90) { progressLabel.Text = "90%"; }
if (progressBar1.Value == 100) { progressLabel.Text = "100%"; }
Take the 2-minute tour
×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.
|
||||
closed as unclear what you're asking by Jamal♦ Jul 8 at 21:16Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question. |
||||
Why can't you do:
As @MNZ pointed out I potentially didn't answer the question exactly how the OP asked. So here's a slightly modified alternative option:
And a unit test to confirm:
|
|||||||||
|
Assuming that you are using a standard WinForms progress bar, you shouldn't have to worry about the progressBar.Value being <0 or >100. |
|||
|
Use a switch statement...
etc... |
|||||||||||||||||||||
|
if..else if
rather than severalif
statements. it would hit one, show it and exit the code until the next iteration of the code – Malachi Sep 13 '13 at 14:43