发布网友
共1个回答
热心网友
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);
}
}