0

基本上我试图让我的进度条出现在不同的级别和颜色,具体取决于返回的值,但是我的 2 个进度条看起来总是彼此相同,即使它们的值不同。此外,颜色也不会更新。

 double DFuelLvl = client.GetTankAmounts("Diesel"); 
            double PFuelLvl =  client.GetTankAmounts("Unleaded");

            if (DFuelLvl < 300)
            {
                DieselBar.Value = 10;
                DieselBar.ForeColor = Color.Red;
                DieselBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
            }
            else if( DFuelLvl > 300 && DFuelLvl< 500)
            {
                DieselBar.Value = 35;
                DieselBar.ForeColor = Color.Orange;
                DieselBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
            }
            else if (DFuelLvl > 500 && DFuelLvl < 850)
           {
               DieselBar.Value = 75;
               DieselBar.ForeColor = Color.Green;
               DieselBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
           }
            else
            {
                DieselBar.Value = 100;
                DieselBar.ForeColor = Color.Blue;
                DieselBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
            }

            if (PFuelLvl < 300)
            {
                Petrolbar.Value = 10;
                Petrolbar.ForeColor = Color.Red;
                Petrolbar.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
            }
            else if (PFuelLvl > 300 && DFuelLvl < 500)
            {
                Petrolbar.Value = 35;
                Petrolbar.ForeColor = Color.Orange;
            }
            else if (PFuelLvl > 500 && DFuelLvl < 850)
            {
                Petrolbar.Value = 75;
                Petrolbar.ForeColor = Color.Green;
            }
            else
            {
                Petrolbar.Value = 100;
                Petrolbar.ForeColor = Color.Blue;
            }
4

1 回答 1

0

禁用视觉样式,并在颜色更改后更新布局就足够了。

于 2013-04-12T10:53:31.860 回答