Solved

c# progressbar with number% displayed inside progress bar

Posted on 2011-03-15
7
3,251 Views
Last Modified: 2013-12-17
Hi,

I'd like to display %number inside the progress bar. I don't know how to do it?
Could you advise me on it?

Thanks,
JT
0
Comment
Question by:jtran007
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 10

Expert Comment

by:Asim Nazir
ID: 35136839
0
 
LVL 8

Expert Comment

by:jimsweb
ID: 35136876
Using simple calculations you can do that. try this:

int cal_percent = (int)(((double)(myprogressBar.Value - myprogressBar.Minimum) /
(double)(myprogressBar.Maximum - myprogressBar1.Minimum)) * 100);

on the other hand, if you are looking for some kind of tutorials, u can get it from here.
dreamincode.net/forums/topic/62979-add-the-percent-into-a-progress-bar/
0
 
LVL 26

Accepted Solution

by:
EDDYKT earned 250 total points
ID: 35136880
private void SetProgressBarText(ProgressBar Target, Color TextColor, Font TextFont, int percentage)
        {
            string Text = percentage + "%";
            using (Graphics gr = Target.CreateGraphics())
            {
                gr.DrawString(Text, TextFont, new SolidBrush(TextColor),
                    new PointF(Target.Width / 2 - (gr.MeasureString(Text, TextFont).Width / 2.0F),
                        Target.Height / 2 - (gr.MeasureString(Text,
                        TextFont).Height / 2.0F)));
            }
        }


To use

SetProgressBarText(progressBar1, Color.Black, new Font("Courier new", 10, FontStyle.Bold), 10);
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Expert Comment

by:Mohamed Abowarda
ID: 35143275
0
 
LVL 12

Expert Comment

by:Mohamed Abowarda
ID: 35143282
0
 
LVL 12

Expert Comment

by:Mohamed Abowarda
ID: 35143293
0
 

Author Closing Comment

by:jtran007
ID: 35269021
Thanks,
JT
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Get month and date in a format 4 45
Why use this lambda? 12 64
C# Linq - Join two objects into one 3 35
C# DataTable (in memory) vs SQL Lookups 4 36
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question