My program is a testing. When giving a correct answer, my Progress Bar
is increased, but I want to show a percentage of correct answers. I use next code, that I found in the net:
progressBar1.PerformStep();
int percent = (int)(((double)progressBar1.Value /
(double)progressBar1.Maximum) * 100);
progressBar1.CreateGraphics().DrawString(
percent.ToString() + "%",
new Font("Arial", (float)8.25, FontStyle.Regular),
Brushes.Black,
new PointF(progressBar1.Width / 2 - 10, progressBar1.Height / 2 - 7));
I place this code in the answer_but_click
event. answer_but
is a button that checks your answer, define whether it is true or false and counts a general number of given correct answers. Percentage appears for a milisecond and thet disappers. What's the problem?