class DataGridViewProgressColumn : DataGridViewImageColumn
{
public DataGridViewProgressColumn()
{
this.CellTemplate = new DataGridViewProgressCell();
}
}
class DataGridViewProgressCell : DataGridViewImageCell
{
public object progressCellLock = new object();
public Image emptyImage;
public DataGridViewProgressCell()
{
this.ValueType = typeof(double);
emptyImage = new Bitmap(1, 1, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
}
protected override object GetFormattedValue(object value,
int rowIndex, ref DataGridViewCellStyle cellStyle,
TypeConverter valueTypeConverter,
TypeConverter formattedValueTypeConverter,
DataGridViewDataErrorContexts context)
{
return emptyImage;
}
public new double Value
{
set
{
lock (progressCellLock)
{
try
{
base.Value = Math.Round(value, 2);
}
catch { }
}
}
get
{
return double.Parse(base.Value.ToString());
}
}
private int Height = 23;
private int Width = 210;
private Color progressColor = System.Drawing.Color.FromArgb(((int)(((byte)(67)))), ((int)(((byte)(222)))), ((int)(((byte)(166)))));
protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
{
base.Paint(g, clipBounds, cellBounds,
rowIndex, cellState, value, formattedValue, errorText,
cellStyle, advancedBorderStyle, (paintParts & ~DataGridViewPaintParts.ContentForeground));
Graphics graphics = g;
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
using (Pen pen5 = new Pen(Color.White, Height - 2))
{
pen5.StartCap = LineCap.Round;
pen5.EndCap = LineCap.Round;
graphics.DrawLine(pen5, cellBounds.X + 30, cellBounds.Y + 30, cellBounds.X + Width + 30, cellBounds.Y + 30);
}
using (Pen pen6 = new Pen(progressColor, Height - 2))
{
pen6.StartCap = LineCap.Round;
pen6.EndCap = LineCap.Round;
int num4 = 0;
if (Value > 0) num4 = (int)Math.Ceiling(Width * Value);
graphics.DrawLine(pen6, cellBounds.X + 30, cellBounds.Y + 30, cellBounds.X + num4 + 30, cellBounds.Y + 30);
}
}
}
DataGridView进度条 DataGridViewProgressColumn
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
相关阅读更多精彩内容
- https://github.com/fems1888/SelfTestLib
- 先上效果图: Demo地址: https://github.com/liys666666/LiysProgress...
- 这篇介绍的是CAShaperLayer制作一个直线进度条,圆环进度条,注水动画;话不多说,直接代码 GitHub工...
- 大家好,今天给大家介绍一部科幻电影《人工智能 灭绝危机》 生化危机之后,地球被毁坏,人们只能躲在地下避难。地球的环...