发布网友 发布时间:2024-10-23 22:27
共1个回答
热心网友 时间:2024-10-31 21:10
public partial class CustomProgressBar : ProgressBar
{
public CustomProgressBar()
{
InitializeComponent();
this.SetStyle(ControlStyles.UserPaint, true);
}
protected override void OnPaint(PaintEventArgs pe)
{
this.ForeColor = Color.FromArgb(255 * this.Value / 100, 255 - 255 * this.Value / 100, 255);
var width = this.Value * this.Width / this.Maximum;
pe.Graphics.FillRectangle(new SolidBrush(this.ForeColor), 0, 0, width, this.Height);
base.OnPaint(pe);
}
}