Reputation: 181
I am using windows progressbar. I want to show different color gradient in this progressbar.
prim1.BackColor = Color.FromArgb(252, 115, 115); prim1.BackColor2 = Color.FromArgb(253, 33, 33); prim1.BackColor3 = Color.FromArgb(253, 33, 33); prim1.BackColor4 = Color.FromArgb(252, 115, 115);
These gradient sets me to show different shades of the color. This was possible in RadProgressbar.Is this possible in windows progressbar?
Upvotes: 0
Views: 2011
Reputation: 942128
You have to replace it, the native Windows progress bar doesn't support custom colors when visual styles are enabled. The colors are selected by the theme that the user preferred. Replacing the progress bar used to be quite easy, it didn't do anything fancy. That got to be a lot harder at Vista though when it got the sub-step interpolation and animation features. Reproducing that takes a lot of code that you probably don't want to maintain.
Realistically, make your own by deriving a class from Control, using LinearGradientBrush or PathGradientBrush in the OnPaint method and keep it static. Or stick with what the user selected, she won't be disappointed.
Upvotes: 1
Reputation: 50692
A quick tip: be very careful when creating a progressbar that requires a lot of calculations/CPU time.
Most of the time when you need a progressbar you use it to give feedback on a long running process, that process needs CPU time and by introducing a costly progressbar you might be stretching that process more than you would want.
Upvotes: 1
Reputation: 33272
For sure you can, but not out of the box ( with Winform ). You have to do an Owner Drawn progress bar, and I think you can start from here: Animated "glow" in owner-drawn Progress Bar (ListView/DataGridView) Not exactly the same of you but I think you will have good material to start up.
Upvotes: 0