C# Progressbar在+-90%

C# Progressbar在+-90%,c#,user-interface,progress-bar,C#,User Interface,Progress Bar,我正在做一个问答程序,你有15秒的时间回答一个问题。问题是进度条只填充了90%左右,然后转到下一个问题。我可以把代码放在这里,但我用荷兰语工作过,所以可能很难理解 private void volgendeVraagFormButton_Click(object sender, EventArgs e) { //button for going to next question vraagFormulierProgressBar.Value = 0

我正在做一个问答程序,你有15秒的时间回答一个问题。问题是进度条只填充了90%左右,然后转到下一个问题。我可以把代码放在这里,但我用荷兰语工作过,所以可能很难理解

    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();
        }
    }
private void volgendeVraagFormButton_单击(对象发送方,事件参数e)
{
//用于转到下一个问题的按钮
vraagFormulierProgressBar.Value=0;
vraagFormulierTimer.Start();
}
私有void vraagFormulierTimer_Tick(对象发送方,事件参数e)
{
if(vraagFormulierProgressBar.Value
以下是相同的英文代码和变量名:

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();
    }
}
private void nextQuestionFormButton\u单击(对象发送方,事件参数e)
{
//用于转到下一个问题的按钮
questionFormProgressBar.Value=0;
questionFormTimer.Start();
}
private void questionFormTimer_Tick(对象发送方,事件参数e)
{
如果(questionFormProgressBar.Value查看以下内容:

因此,尝试将进度条增加2,然后减少1。这应该可以解决动画问题

编辑
另外,请更改此行

if (vraagFormulierProgressBar.Value < vraagFormulierProgressBar.Maximum)
if(vraagFormulierProgressBar.Value
对此

if (vraagFormulierProgressBar.Value + 1 < vraagFormulierProgressBar.Maximum)
if(vraagFormulierProgressBar.Value+1
编辑2
好的,这次我知道了。首先,将进度条的最大值设置为300,间隔设置为1(您可以稍后确定计时)。接下来,用以下内容替换计时器勾号功能:

            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();
            }
if(progressBar1.Value

很抱歉使用了英文名称,我从我的测试表中复制了这个名称。无论如何,希望这有帮助!

您可能需要执行查找/替换操作,并将其更改为英文变量。这将帮助您查找和回答。请继续,删除与显示您不想要的行为的进度条无关的所有内容。When如果您完成了,您可能已经解决了您的问题。如果您不这样做,您至少可以提出一些有用的问题。@Timbo我已经编辑了代码。请阅读ProgressBar.PerformStep()的文档。相应地设置MinValue、MaxValue和Step属性。现在您将递增3,因此请尝试取出
performstep()
非常感谢。它运行得更好,但仍不能满足100%的需求。这里有一些变化:我如何才能使它更好?尝试添加
vraagFormulierProgressBar.Value=vraagFormulierProgressBar.Maximum;
的开头,否则
声明非常感谢您的工作,非常感谢,现在是凌晨2点,我终于可以去了睡觉!!!:)没问题,很高兴我能帮忙。另外,如果这是答案,请关闭问题。