Here is a full working proposition of solution to the custom progress bar.
こちらのみたいですよろしくお願いいたします
Here is a full working proposition of solution to the custom progress bar.
こちらのみたいですよろしくお願いいたします
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.
9 people are following this question.