dotnetbar2里面的progressbarx控件,进度条颜色怎么改
展开全部
改变系统自带进度条的方法就是重绘了。
具体方法如下:
1. 自定义控件继承自ProgressBar,如下:
public class CustomProgressBar : ProgressBar
{
public CustomProgressBar()
{
base.SetStyle(ControlStyles.UserPaint, true);
//...
}
//重写OnPaint方法
protected override void OnPaint(PaintEventArgs e)
{
SolidBrush brush = null;
Pen pen;
Rectangle bounds = new Rectangle(0, 0, base.Width, base.Height);
//...
e.Graphics.FillRectangle(new SolidBrush(this.BackColor), 1, 1, bounds.Width - 2, bounds.Height - 2);
bounds.Height -= 4;
具体方法如下:
1. 自定义控件继承自ProgressBar,如下:
public class CustomProgressBar : ProgressBar
{
public CustomProgressBar()
{
base.SetStyle(ControlStyles.UserPaint, true);
//...
}
//重写OnPaint方法
protected override void OnPaint(PaintEventArgs e)
{
SolidBrush brush = null;
Pen pen;
Rectangle bounds = new Rectangle(0, 0, base.Width, base.Height);
//...
e.Graphics.FillRectangle(new SolidBrush(this.BackColor), 1, 1, bounds.Width - 2, bounds.Height - 2);
bounds.Height -= 4;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询