0

I am making a Q&A program where you have 15 sec to answer a question. The problem is that the progress bar is only filling like 90% and moves to the next question. I can put the code here but I have worked in Dutch so maybe it's difficult to understand.

    private void volgendeVraagFormButton_Click(object sender, EventArgs e)
    {
        //button for going to next question
        vraagFormulierProgressBar.Value = 0;
        vraagFormulierTimer.Start();
    }

    private void vraagFormulierTimer_Tick(object sender, EventArgs e)
    {
        if (vraagFormulierProgressBar.Value < vraagFormulierProgressBar.Maximum)
            vraagFormulierProgressBar.PerformStep();
            //checks if the value is lower than 15 sec(max)
        else
        {      //stops the progress if the 15 secs are over and moves to next question
            vraagFormulierTimer.Stop();
            vraagFormulierProgressBar.Value = 0;
            vraagFormulierTimer.Start();
        }
    }

Here's the same code with variable names in English:

private void nextQuestionFormButton_Click(object sender, EventArgs e)
{
    //button for going to next question
    questionFormProgressBar.Value = 0;
    questionFormTimer.Start();
}

private void questionFormTimer_Tick(object sender, EventArgs e)
{
    if (questionFormProgressBar.Value <questionFormProgressBar.Maximum)
       questionFormProgressBar.PerformStep();
        //checks if the value is lower than 15 sec(max)
    else
    {      //stops the progress if the 15 secs are over and moves to next question
       questionFormTimer.Stop();
       questionFormProgressBar.Value = 0;
       questionFormTimer.Start();
    }
}
Gurpreet.S
  • 89
  • 1
  • 9
  • 1
    You may want to do a Find/Replace and change what you can to English variables. It will help you find and answer – arserbin3 May 17 '14 at 21:12
  • 2
    Just go ahead and delete everything that does not have anything to do with the progress bar showing the behaviour you do not want. When you are done with that, you probably have solved your problem. If you don't, you will at least have something that may make a useful question. – Timbo May 17 '14 at 21:14
  • http://stackoverflow.com/questions/2583062/c-sharp-progressbar-is-not-updated-accurately-in-vista-or-windows7 – jmelhus May 17 '14 at 21:15
  • Read the documentation for ProgressBar.PerformStep(). Set the MinValue, MaxValue and Step properties accordingly. – CodeCaster May 17 '14 at 21:44
  • @Gurpreet.S, please tag this question with a ui designation. it will attract more people. – Gayot Fow May 17 '14 at 22:58

1 Answers1

1

Take a look at this: Disabling .NET progressbar animation when changing value?
So try to increment your progress bar by 2, then decrement by 1. That should fix the animation problem

Edit
Also, change this line

if (vraagFormulierProgressBar.Value < vraagFormulierProgressBar.Maximum)

to this

if (vraagFormulierProgressBar.Value + 1 < vraagFormulierProgressBar.Maximum)

Edit 2
OK, I've got it this time. First, set the maximum of your progress bar to 300 and the interval to 1 (You can fix the timing later). Next, replace the timer tick function with this:

            if (progressBar1.Value < progressBar1.Maximum - 1)
            {
                progressBar1.Increment(2);
                progressBar1.Increment(-1);
            }
            else
            {
                timer1.Stop();

                progressBar1.Maximum = 10000;
                progressBar1.Value = 10000;
                progressBar1.Value = 9999;
                progressBar1.Value = 10000;
                System.Threading.Thread.Sleep(150);

                progressBar1.Value = 0;
                progressBar1.Maximum = 300;
                timer1.Start();
            }

Sorry about using the English names, I copied this out of my test form. Anyway, hope this helps!

Community
  • 1
  • 1
Blue0500
  • 715
  • 8
  • 16
  • Now you are incrementing by 3, so try taking out the `performstep()` – Blue0500 May 17 '14 at 22:07
  • Thanks alot. It's working better but still not filling 100%, need like 5% more. Here are changes: http://puu.sh/8QjpS.png How can I make it better? – Gurpreet.S May 17 '14 at 22:10
  • Try adding `vraagFormulierProgressBar.Value = vraagFormulierProgressBar.Maximum;` at the beginning of the `else` statement – Blue0500 May 17 '14 at 22:17
  • Really appreciate your work, thanks alot, it's 2am and I can finally go to sleep!!! :) – Gurpreet.S May 17 '14 at 23:17
  • Ya no problem, just glad I could help. Also, please close the question if this was the answer. – Blue0500 May 17 '14 at 23:19