表格统计有时有各种需求,比如进度。。。
找一遍没有找到现成的控件。
就想简单的搞一下,不要太麻烦,DataGrid的ColumnType类型里只有:
在这里抓挠,琢磨下也就Button和Image能用。
最终选择image。说来也简单,就是自己画图。
直接上代码:
public int press { get; set; }//进度
public Image PressImg//进度条图片属性
{
get
{
Font f_font = new Font("Arial", 16, FontStyle.Bold);
Bitmap bmp = new Bitmap(100, 30);
Graphics g = Graphics.FromImage(bmp);
g.Clear(Color.LightGray);
g.FillRectangle(new LinearGradientBrush(new Point(30, 2), new Point(30, 30), Color.Green, Color.Gray), 2, 2, this.press, 26);
g.DrawString(this.press.ToString()+"%", f_font, Brushes.LimeGreen, 3, 6);
return bmp;
}
}
两个属性,根据进度 绘制Image 绑定到表格即可。
参考参考直接用。
经济不好,反而很忙,好久没写留个脚印,省的自己忘记了。