DataGridView显示进度条列

先看看效果,如果感兴趣,继续往下看……

效果如下图所示:

DataGridView里没有Pragress列,但有Image列,有了它我们可以自己绘图来实现进度条。其实实现起来并不困难。

首先在实体类增加Image类型的属性,在get里绘制进度条图片:


using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;

namespace DataGridViewProgress
{
public class UserInfo
{
public string UserName { get; set; }
public string Addr { get; set; }
public int Press { get; set; }

//进度条图片属性
public Image PressImg
{
get
{
Bitmap bmp = new Bitmap(104, 30); //这里给104是为了左边和右边空出2个像素,剩余的100就是百分比的值
Graphics g = Graphics.FromImage(bmp);
g.Clear(Color.White); //背景填白色
//g.FillRectangle(Brushes.Red, 2, 2, this.Press, 26); //普通效果
//填充渐变效果
g.FillRectangle(new LinearGradientBrush(new Point(30, 2), new Point(30, 30), Color.Black, Color.Gray), 2, 2, this.Press, 26);
return bmp;
}
}
}
}

然后在DataGridView里添加图片列并绑定DataPropertyName属性:

运行起来,大功告成!

时间: 2024-08-04 19:07:45

DataGridView显示进度条列的相关文章

【CentOS】cp显示进度条

问题描述: 使用CentOS的cp时,对于大文件的拷贝或者mv,需要等待很长时间,现在需要显示cp或mv的进度 问题解决: Advanced copy 参考官网:http://beatex.org/web/advancedcopy.html 解决方法: 效果预览: [CentOS]cp显示进度条,码迷,mamicode.com

【原创】用JAVA实现大文件上传及显示进度信息

用JAVA实现大文件上传及显示进度信息 ---解析HTTP MultiPart协议 一. 大文件上传基础描述: 各种WEB框架中,对于浏览器上传文件的请求,都有自己的处理对象负责对Http MultiPart协议内容进行解析,并供开发人员调用请求的表单内容. 比如: Spring 框架中使用类似CommonsMultipartFile对象处理表二进制文件信息. 而.NET 中使用HtmlInputFile/ HttpPostedFile对象处理二进制文件信息. 优点:使用框架内置对象可以很方便的

097在进度条中显示进度百分比

效果如下: ViewController.h 1 #import <UIKit/UIKit.h> 2 #import "KMProgressViewWithLabel.h" 3 4 @interface ViewController : UIViewController 5 @property (strong, nonatomic) KMProgressViewWithLabel *progressViewCustom; 6 7 @end ViewController.m

easyui datagrid控制显示进度条

实际项目中当我们在前台分页的时候需要控制datagrid加载数据时显示进度条,而datagrid默认只有在通过url方式加载数据时才显示进度条,以下代码是手动控制: 打开进度条: $('#searchAddrDg').datagrid('loading');//打开等待div 关闭进度条: $('#searchAddrDg').datagrid('loaded');//关闭loding进度条:

ProgressIndicator显示进度条以及一些文字信息

//ProgressIndicator可以显示进度条以及一些文字信息,不过这个属性一般都在cs文件中操作. private void PhoneApplicationPage_Loaded(object sender, System.Windows.RoutedEventArgs e) {     private Microsoft.Phone.Shell.ProgressIndicator _progressIndicator = new Microsoft.Phone.Shell.Progr

复制文件时,如何显示进度条(使用TFileStream一点一点读,或者使用BlockRead)

procedure mycopyfile(sourcef,targetf:string;i:integer); var FromF,ToF:file; NumRead,NumWritten:Integer; Buf:array[1..2048] of Char; n:integer; begin AssignFile(FromF,sourcef); Reset(FromF, 1); { Record size = 1 } AssignFile(ToF,targetf); { Open outpu

显示进度条

static void jindutiao_ZF(Args _args){ RunBaseProgress progress; integer i,j;; i = 10000; progress = new RunBaseProgress(1); progress.setCaption('进度');progress.setTotal(i); progress.updateInterval(1); while(j != i) { j =j+100; progress.setCount(j); pr

基于Jquery插件Uploadify实现实时显示进度条上传图片

网址:http://www.jb51.net/article/83811.htm 这篇文章主要介绍了基于Jquery插件Uploadify实现实时显示进度条上传图片的相关资料,感兴趣的小伙伴们可以参考一下 先了解了解Uploadify,具体内容如下 Uploadify是一个简单易用的多文件上传方案.作为一个Jquery插件,Uploadify使用简单,并具有高度的定制性. Uploadify特性: Uploadify简单说来,是基于Jquery的一款文件上传插件.它的功能特色总结如下: 1).支

UISlider显示进度

图片展示效果如下: 其他没什么好说的,直接上代码: RootView.h: 1 #import <UIKit/UIKit.h> 2 3 @interface RootView : UIView 4 @property (nonatomic, strong) UISlider *slider; 5 @property (nonatomic, strong) UILabel *label; 6 7 @end RootView.m: 1 #import "RootView.h"