• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 49
  • Last Modified:

C# How to show percentage complete?

I have a progress bar appearing on the screen and I would like to display the percentage complete right above the bar. I tried updating a label but all that displayed was 0.

                        progressBar1.PerformStep();

                        if (i % 50 == 0)
                        {
                            this.Refresh();
                            Application.DoEvents();
                        }

                        ProgressBarPercentage = (progressBar1.Value / progressBar1.Maximum) * 100;

What would I need to add to this code to get the percentage to appear?
0
rwheeler23
Asked:
rwheeler23
  • 2
2 Solutions
 
Ryan ChongCommented:
check this out, it seems we need to do something in progressBar's Paint event

Display text on a ProgressBar in C#
http://csharphelper.com/blog/2016/07/display-text-progressbar-c/
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
Is this not what you wanted ?

progressBar1.PerformStep();
ProgressBarPercentage = (progressBar1.Value / progressBar1.Maximum) * 100;
                        if (ProgressBarPercentage  % 50 == 0)
                        {
labelprogress.Text = "50";  //where labelprogress is the name of your label
                            this.Refresh();
                            Application.DoEvents();
                        }
0
 
rwheeler23Author Commented:
Thanks, it appears it needs more than just setting a property. I have it now that it goes 10%, 20%....100% as the progress bar moves from left to right.
0
 
rwheeler23Author Commented:
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now