利用devexpress的gridcontrol添加进度条

panxinxian panxinxian     2022-12-19     174

关键词:

第一步:在一个窗体中添加一个GridControl控件,如图所示:

 

技术分享图片

第二步:点击控件中的Run Designer,找到Columns,然后再选择要设置进度条的列,设置属性如下:

技术分享图片

第三步:点击View,找到事件CustomDrawCell,写如下的代码:

技术分享图片

private void gridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)

if (e.RowHandle == gridView1.FocusedRowHandle)

e.Appearance.BackColor = Color.CadetBlue;

if (e.Column.FieldName == "ZBJD")//为ZBJD这列设置进度条

DrProgressBar(e);
e.Handled = true;
DrawEditor(e);

private void DrProgressBar(DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)

decimal percent = Convert.ToDecimal(e.CellValue);
int iIndex = 0;
int width = 0;
if (percent < 0.0000001m)

iIndex = 1;

if (iIndex == 1)

width = (int)(100 * Math.Abs(1) * e.Bounds.Width / 100);

else

width = (int)(100 * Math.Abs(percent) * e.Bounds.Width / 100);


Rectangle rect = new Rectangle(e.Bounds.X, e.Bounds.Y, width, e.Bounds.Height);
Brush b = Brushes.Green;
if (percent < 1)

b = Brushes.Red;

else

b = Brushes.Green;

e.Graphics.FillRectangle(b, rect);

private void DrawEditor(DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)

GridCellInfo cell = e.Cell as GridCellInfo;
Point offset = cell.CellValueRect.Location;
BaseEditPainter pb = cell.ViewInfo.Painter as BaseEditPainter;
AppearanceObject style = cell.ViewInfo.PaintAppearance;
if (!offset.IsEmpty)
cell.ViewInfo.Offset(offset.X, offset.Y);
try

pb.Draw(new ControlGraphicsInfoArgs(cell.ViewInfo, e.Cache, cell.Bounds));

finally

if (!offset.IsEmpty)

cell.ViewInfo.Offset(-offset.X, -offset.Y);

 
 

 最后效果如下:

技术分享图片

注意事项:当你的百分比显示不出来的时候,设置进度条这列的ColumnEdit一定不要像其它笔者一样设置一个ProgressBar进度条。当初自己就按照其它笔者的来做,数值总是不显示,一直困扰了我好多天,所以在这里提醒大家一下。在下黎希,以后我会常在博客里写入有关ArcGIS二次开发的内容,希望和大家一起交流学习!

                                                                                  




























































devexpress中gridcontrol添加复选框只能选中一个

我在gridcontrol中想做一个通过添加一列复选框(checkedit)实现多个行的选择功能我实现的方法:在一列中添加一个复选控件但是它只能选择一个行,选择另一行时,被选中的就会取消效果就是单选按钮的效果不知道为什么?已经用... 查看详情

[devexpress]gridcontrol分页的实现

添加两个组件:BindingNavigator和BindingSource代码:usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Data.SqlClient;usingSystem.Drawing;usingSystem.Text;usingSys 查看详情

devexpress之gridcontrol自定义列

...个框架实现B/S或C/S的,都是非常出色的。本文主要讨论下GridControl中如何【自定义列】或【计算列】,可使用以下两种方法实现: 1.  方法一使用DevExpress.XtraGrid.Columns.GridColumn的UnboundExpression与UnboundType属性,步骤 查看详情

devexpress控件的gridcontrol怎么添加下拉数据

参考技术A首先,在界面创建一个数据源,并将次数据源绑定为gridControl的datesoure属性最后在你的后台给此数据源绑定数据 查看详情

[devexpress]gridcontrol分页的实现

加入两个组件:BindingNavigator和BindingSource代码:usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Data.SqlClient;usingSystem.Drawing;usingSystem.Text;usingSys 查看详情

devexpress使用之:gridcontrol控件

 Devexpress系列控件功能很强大,使用起来也不太容易,我也是边摸索边使用,如果有时间我会把常用控件的使用方法整理出来的。 usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Windows.Forms;usingDevExpress.XtraGr... 查看详情

devexpress.xtragrid.gridcontrol实现自定义tooltip

DevExpress.XtraGrid.GridControl控件默认的tooltip显示的每一个单元格的文本值,但是实际工作中会出现各种需求。我这里就有一个列是折扣率显示的值是0-1之间的两位小数,比如说0.55想要显示成五五折。那就需要自己来做一下处理了(... 查看详情

如何给devexpress中的gridcontrol添加列

...A从VisualStudio的DevExpress的工具箱“Data&Analytics”中拖一个GridControl控件到窗体中。点击GridControl控件上的“RunDesigner”按钮,弹出GridDesigner窗体,在该窗体左侧选择“Columns”选项卡,在Columns控制界面中有三个按钮分别可以添加列、... 查看详情

[devexpress]gridcontrol拖拽行记录排序(代码片段)

DevExpress的GridControl拖拽行记录排序需求效果代码需求现在用户对按钮点击排序不满意了,希望拖拽排序。重载GridControl控件,对MouseMove、MouseDown、MouseUp事件修改一下。效果代码usingSystem;usingSystem.Drawing;usingSystem.Windows.Forms 查看详情

devexpress中gridcontrol列转义的实现方法

 ///<summary>///CustomColumnDisplayTextHelper///</summary>///<paramname="girdview">GridView</param>///<paramname="fieldNameHandler">委托</param>///<paramname= 查看详情

用扩展方法实现devexpress-gridcontrol级联效果

...一个参数的类型不能是指针类型。 在DevExpress控件中GridControl是非常常用的控件之一, 查看详情

devexpress实现gridcontrol删除所有行的方法

///<summary>///删除全部行///</summary>///<paramname="gridView">GridView</param>publicstaticvoidClearRows(thisGridViewgridView){bool_mutilSelected=gridView.OptionsSelection.MultiSele 查看详情

devexpress的gridcontrol的使用以及怎样添加列和绑定数据源(代码片段)

...le/details/100061243在上面搭建好DevExpress的环境后,要使用其GridControl控件。注:博客主页:https://blog.csdn.net/badao_liumang_qizhi关注公众号霸道的程序猿获取编程相关电子书、教程推送与免费下载实现首先在窗体中拖拽一个GridControl ... 查看详情

如何给devexpress中的gridcontrol添加列

...、从VisualStudio的DevExpress的工具箱“Data&Analytics”中拖一个GridControl控件到窗体中。2、点击GridControl控件上的“RunDesigner”按钮,弹出GridDesigner窗体,在该窗体左侧选择“Columns”选项卡,在Columns控制界面中有三个按钮分别可以添加... 查看详情

devexpress的gridcontrol之gridview使用困惑?

DevExpress的Gridcontrol控件怎么设置默认排序字段及排序方式。我在数据库查询中已经设置了排序字段。但是Gridcontrol显示时会把查询的结果顺序打乱(还是那些被查询出来的数据。)请高手指点,小弟迷茫中,不胜感激!!这样试... 查看详情

[devexpress]gridcontrol轮播图片(代码片段)

privatevoidgridControl1_Click(objectsender,EventArgse) 查看详情

devexpress的gridcontrol怎么删除网格中的一行

...的添加或删除行,只涉及界面上的操作怎么做?很简单,gridControl一般有GridView1GridView1.AddNewRow()‘添加行GridView1.DeleteSelectedRows()’删除行参考技术A其实在属情中有删除项,只要你勾选了!但是你操作的数据表中如果包含主键的话... 查看详情

devexpress的gridcontrol拖拽draopdown后计算hitinfo的rowhandle错误

  最近在使用GridControl的拖拽功能时候遇到了一个问题:当GridControl触发DropDrop事件时,计算对应的RowHandle错误。当把鼠标拖拽到GridView一个单元格的靠上面的部分时,显示为较小的一个RowHandle;当拖拽到单元格靠下面的部分的... 查看详情