代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
C#
】
带有进度条的listView
作者:
Calvin
/ 发布于
2016/2/1
/
589
使用方法,数据加载 后,设置progressColumnIndex 属性即可
public class ListViewProgress : System.Windows.Forms.ListView { private string progressText; private System.Drawing.Color progressBackColor; public System.Drawing.Color ProgressBackColor { get { return progressBackColor; } set { progressBackColor = value; } } private System.Drawing.Color progressTextColor; public System.Drawing.Color ProgressTextColor { get { return progressTextColor; } set { progressTextColor = value; } } private int progressColumnIndex = -1; public int ProgressColumnIndex { get { return progressColumnIndex; } set { progressColumnIndex = value; } } public ListViewProgress() { this.Name = "ProgressListView"; this.progressBackColor = System.Drawing.Color.YellowGreen; this.progressTextColor = base.ForeColor; this.OwnerDraw = true; } protected override void OnDrawColumnHeader(System.Windows.Forms.DrawListViewColumnHeaderEventArgs e) { e.DrawDefault = true; base.OnDrawColumnHeader(e); } protected override void OnDrawSubItem(System.Windows.Forms.DrawListViewSubItemEventArgs e) { if (e.ColumnIndex == this.ProgressColumnIndex) { //画进度条 System.Drawing.Graphics ProgressGraphics = e.Graphics; System.Drawing.Rectangle ProgressRect = new System.Drawing.Rectangle( e.Bounds.Left, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height); if (ProgressRect.Height > 6 && ProgressRect.Width > 6) { //调整为新的区域,以便产生一定间距 ProgressRect = new System.Drawing. Rectangle(e.Bounds.Left + 2, e.Bounds.Top + 2, e.Bounds.Width - 5, e.Bounds.Height - 5); Single Percent = 0; try { Percent = Convert.ToSingle(e.SubItem.Text); } catch { Percent = 0; } if (Percent > 1.0f) Percent = Percent / 100.0f; //外框 ProgressGraphics.FillRectangle(System.Drawing.Brushes.White, ProgressRect); ProgressGraphics.DrawRectangle(new System.Drawing.Pen(e.SubItem.ForeColor), ProgressRect); //内容 System.Drawing.Rectangle ProgressContentRect = new Rectangle( ProgressRect.Left + 1, ProgressRect.Top + 1, (int)(ProgressRect.Width * Percent) - 1, ProgressRect.Height - 1 ); ProgressGraphics.FillRectangle(new System.Drawing.SolidBrush(progressBackColor), ProgressContentRect); //输出文字 if (e.SubItem.Font.Height < ProgressRect.Height) { ProgressRect = new System.Drawing.Rectangle(ProgressRect.Left, ProgressRect.Top - ((ProgressRect.Height - e.SubItem.Font.Height) / 2), ProgressRect.Width, ProgressRect.Height); } else { ProgressRect = new System.Drawing.Rectangle(e.Bounds.Left, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height); } using (StringFormat sf = new StringFormat()) { sf.Alignment = System.Drawing.StringAlignment.Center; sf.LineAlignment = System.Drawing.StringAlignment.Center; sf.Trimming = System.Drawing.StringTrimming.EllipsisCharacter; e.Graphics.DrawString(Percent.ToString("p1"), e.SubItem.Font, new System.Drawing.SolidBrush(this.progressTextColor), ProgressRect, sf); } } base.OnDrawSubItem(e); } else { e.DrawDefault = true; base.OnDrawSubItem(e); } } }
试试其它关键字
进度条
同语言下
.
C#实现的html内容截取
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
网站后台修改图片尺寸代码
.
处理大图片在缩略图时的展示
.
实现对图片上传的接收
.
去除字符串中的空格,回车,换行符转变成‘;’在按‘
.
按照回车换行符分割字符串
.
文件MD5码 比较,检测文件是否一样
可能有用的
.
C#实现的html内容截取
.
List 切割成几份 工具类
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
.
处理大图片在缩略图时的展示
Calvin
贡献的其它代码
(
9
)
.
c# 操作PPT
.
带有进度条的listView
.
内存使用检测
.
交互式命令行,命令行执行 PHP
.
DEBUG 查看调用 backtrace
.
接受 PUT 请求,PHP REST 必备
.
列出所有函数,判断某个函数是否存在
.
变量函数名,可以用字符串拼接函数名
.
返回当前会话的cookie的全部键值
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3