You can see : ColorBar - A Gradient Colored ProgressBar
(VB, but same code in C#)
How can I make a multi-colored segmented progress bar in C# Window From
Here is a full working proposition of solution to the custom progress bar.
こちらのみたいですよろしくお願いいたします
3 answers
Sort by: Most helpful
-
Castorix31 81,741 Reputation points
2021-03-10T09:22:07.1+00:00 -
Timon Yang-MSFT 9,576 Reputation points
2021-03-11T02:34:22.647+00:00 One way is to derive your own progressbar from the progressbar control, and then use PathGradientBrush or LinearGradientBrush to paint its color in the OnPaint method.
An example using PathGradientBrush:
public class MyProgressBar : ProgressBar { public MyProgressBar() { this.SetStyle(ControlStyles.UserPaint, true); } protected override void OnPaint(PaintEventArgs e) { Rectangle rec = e.ClipRectangle; GraphicsPath path = new GraphicsPath(); path.AddRectangle(rec); PathGradientBrush pthGrBrush = new PathGradientBrush(path); pthGrBrush.CenterColor = Color.FromArgb(255, 0, 0, 255); Color[] colors = { Color.Red,Color.Yellow}; pthGrBrush.SurroundColors = colors; rec.Width = (int)(rec.Width * ((double)Value / Maximum)) - 4; if (ProgressBarRenderer.IsSupported) ProgressBarRenderer.DrawHorizontalBar(e.Graphics, e.ClipRectangle); rec.Height = rec.Height - 4; e.Graphics.FillRectangle(pthGrBrush, 2, 2, rec.Width, rec.Height); } }
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread. -
johnny8351 1 Reputation point
2021-03-11T05:39:26.21+00:00 you might mean this --> https://www.codeproject.com/Articles/31216/NeroBar