Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#Progressbar在Vista或Windows7中未准确更新_C#_Progress Bar - Fatal编程技术网

C#Progressbar在Vista或Windows7中未准确更新

C#Progressbar在Vista或Windows7中未准确更新,c#,progress-bar,C#,Progress Bar,这里我使用了一个计时器来更新进度条的值。它在XP中运行良好。但在Windows7或Vista中,当进度值设置为100,但图形进度不是100 搜索某些线程时,发现其在Vista/Windows7中的动画延迟 如何摆脱这个东西 我不想失去Vista/Window7的外观和感觉,请使用: public partial class Form1 : Form { //.... private void timer1_Tick(object sender, EventArgs e) {

这里我使用了一个计时器来更新进度条的值。它在XP中运行良好。但在Windows7或Vista中,当进度值设置为100,但图形进度不是100

搜索某些线程时,发现其在Vista/Windows7中的动画延迟

如何摆脱这个东西

我不想失去Vista/Window7的外观和感觉,请使用:

public partial class Form1 : Form
{
  //....
  private void timer1_Tick(object sender, EventArgs e)
  {
     if (this.progressBar1.Value >= 100)
     {
         this.timer1.Stop();
         this.timer1.Enabled = false;
     }
     else
     {
         this.progressBar1.Value += 10;
         this.label1.Text = Convert.ToString(this.progressBar1.Value);                
     }
  }
  //......
}

这就是Vista和更高版本中愚蠢的进度条的工作方式

没有解决办法

向Microsoft投诉。

公共部分类表单1:表单
SetWindowTheme(progressBar1.Handle, " ", " ");
{ //.... 私有无效计时器1_刻度(对象发送方,事件参数e) { 如果(this.progressBar1.Value>=100) { this.timer1.Stop(); this.timer1.Enabled=false; } 其他的 { int tempValue=this.progressBar1.Value+10; 如果(tempValue<100&&tempValue>=0) { this.progressBar1.Value=tempValue+1; this.progressBar1.Value=tempValue; } 否则如果(tempValue>=100) { this.progressBar1.Value=100; this.progressBar1.Value=99; this.progressBar1.Value=100; } this.label1.Text=Convert.ToString(this.progressBar1.Value); } } //...... }

else部分使进度条现在看起来正常。但是应该有一些标准的进度条方式。这个想法来自佛子的评论

我也有同样的问题。福兹的提普帮了我。来自Samir的溶液可以正常工作,除非达到最大值(100%)。为了使这项工作也达到100%,必须在之前增加最大值。下面这些对我来说很好

public partial class Form1 : Form
{
  //....
  private void timer1_Tick(object sender, EventArgs e)
  {
    if (this.progressBar1.Value >= 100)
    {
     this.timer1.Stop();
     this.timer1.Enabled = false;
    }
    else
    {
      int tempValue = this.progressBar1.Value + 10;
      if (tempValue < 100 && tempValue >=0 )
      {
       this.progressBar1.Value = tempValue + 1;
       this.progressBar1.Value = tempValue;
      }
      else if (tempValue >= 100)
      {
       this.progressBar1.Value = 100;
       this.progressBar1.Value = 99;
       this.progressBar1.Value = 100;
      }
     this.label1.Text = Convert.ToString(this.progressBar1.Value);                
    }
  }

//......
}
if(NewValue

以下是我用progressbar的正确满标度绘制来解决win7问题的技巧。

你看到了什么?这对我来说就像预期的一样…显示进度的标签=100%完成!但进度条似乎仍然是80%或90%。不是我们想要的,对吗?我假设您在这里使用Windows窗体(因为代码中没有Dispatcher引用),我必须同意codeka,它在这里很有魅力。。。我们需要更多details@TimothyP当前位置这种行为我已经见过一百次了。因此,除非你从未在Vista或更高版本上使用过WinForms,否则你不会注意到。我也看过几次,而且在一秒钟左右的时间内,从0%快速发展到100%时,这种情况经常发生……我认为他们对你的评论投了否决票。如果确实存在这样的错误,你的评论既没有帮助,也没有洞察力,也没有尊重,如果您需要联系新的联系人,devs@microsoft可能会有所帮助。我刚刚在Windows7上测试了这个,就像charm@TimothyP--没有滞后。。。也就是说,进度条更新落后于实时更新。如果值更新缓慢,则可以,但如果值更新迅速,则条会落后很多。
if (NewValue < progressBar.Maximum)
{
  progressBar.Value = NewValue + 1;
  progressBar.Value--;
}
else
{
  progressBar.Maximum++;
  progressBar.Value = progressBar.Maximum;
  progressBar.Value--;
  progressBar.Maximum--;
}
  private void timer1_Tick(object sender, EventArgs e)
    {

        if (progressBar1.Maximum == 1) progressBar1.Maximum = 100;
        if (progressBar1.Value==100) {
            progressBar1.Value = 0;
            return;
        }
        progressBar1.Increment(1);
        if (progressBar1.Value == 100) {
            progressBar1.Value = 1; progressBar1.Maximum = 1;
            progressBar1.Update();
        }
    }