Hello,
I am trying to use the progress bar to change colors based on a value that passes through a series of if statements. If x is below a certain value, change the color of the bar to, for example red, then if its between these two values and so on. However this is not working. I originally tried this with the standard built in progress bar and it also did not work. However, when I stepped through the code it was setting the correct color but not displaying the correct one. I did some research and found out this line Application.EnableVisualStyles() needs to be removed from the program.cs file, which I can't do per my supervisors. I am wondering if the Infragistics version is suffering from the same problem?
Here is a snippet of what I did.
Thank You
if (goal < 100) { if (goal <= (monthlyGoal *0.79)) toolbarProgress.ForeColor = System.Drawing.Color.Red; else if (goal >= (monthlyGoal * 0.80) && goal <= (monthlyGoal * 0.99)) toolbarProgress.ForeColor = System.Drawing.Color.Yellow; else if (goal >= monthlyGoal) toolbarProgress.ForeColor = System.Drawing.Color.Chartreuse; } else if (DateTime.UtcNow > monthEnd) goal = 0; else if (goal > 100) // don't let it be greater than 100 goal = 100;
Hi Sam,
Welcome to our forums!
The right way to go about setting custom background color to UltraProgressBar is through using the Appearance property and turning off the use of the operating system’s themes.
Hi, I will give this a shot and let you know what happens.
Thanks
Hi, I have tried what you mentioned above and it did not work in my project. To check if the project was causing the issue, I made a bogus VS project and tried the code but also did not work. I have attached a picture for reference.
I assume that ValueChanged event is never raised in your sample. In order to force that event to be raised, you have to set the value of the UltraProgressBar outside of the event handler itself or in your case for example within the Form1() constructor after the InitializeComponent() method. For further reference, I attached my testing sample on the bottom of this post.
Ok, I was able to get it going. However, is it possible to make it that progress has only one solid color in it instead of two? I Have tried messing with the properties but no luck. Please advise.
Thank you