...设计一个可以在不同进度显示不同颜色的进度条 1.
发布网友
发布时间:2024-10-23 22:27
我来回答
共3个回答
热心网友
时间:2024-10-31 16:30
这问题回答过了,咋还问?
class CustomProgressBar : Label
{
private int value;
public CustomProgressBar()
{
this.SetStyle(ControlStyles.UserPaint, true);
this.Maximum = 100;
this.BorderStyle = BorderStyle.FixedSingle;
}
[DefaultValue(BorderStyle.FixedSingle)]
public sealed override BorderStyle BorderStyle
{
get { return base.BorderStyle; }
set { base.BorderStyle = value; }
}
public override bool AutoSize { get { return false; } set { } }
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);
}
public override string Text { get { return string.Empty; } set { } }
public int Maximum { get; set; }
public int Value
{
get { return value; }
set
{
if (this.value == value)
return;
this.value = value;
this.Invalidate();
}
}
}
}
热心网友
时间:2024-10-31 16:34
…………这也有人要钱…
热心网友
时间:2024-10-31 16:33
用GDI+就可以做啊,很简单的,进度就是画布的宽度而已,数据变化的时候就用不同颜色的画布就可以了。这都要钱,鄙视!!