Event Data
The event handler receives an argument of typeRowCellCustomDrawEventArgscontaining
data related to this event.
The followingRowCellCustomDrawEventArgsproperties provide information specific to this event.
Property
Description
Appearance
|
Gets the painted element's appearance settings.
|
Bounds
|
Returns a value specifying limits for the drawing area.
|
Cache
|
Gets an object which specifies the storage for the most often used pens, fonts and brushes.
|
Cell
|
Provides information on the painted cell.
|
CellValue
|
Gets the painted cell's value.
|
Column
|
Gets the column whose element is being painted.
|
DisplayText
|
Gets or sets the painted element's display text.
|
Graphics
|
Gets an object used to paint.
|
Handled
|
Gets or sets a value specifying whether an event was handled and that the default actions are therefore not required.
|
RowHandle
|
Gets the handle of a painted element's row.
|
事件包含的参数主要是上面列表展示的数据,在实际的开发中我们需要用到的主要参数也就是这几个,使用的流程是这样的,
1.判断列名称用到Column属性
2.判断单元格的值用到CellValue属性
3.根据单元格的值,设置我们想要的效果,若设这DisplayText,设置Appearence
4.e.Handled设置为true(大部分情况)
Remarks
TheCustomDrawCellevent is raised before a data cell is painted. The cell that is going to be painted is identified by theRowCellCustomDrawEventArgs.RowHandleandRowCellCustomDrawEventArgs.Columnparameters.
There are two scenarios for using theCustomDrawCellevent:
注意事项:
1.事件发生在数据被绘制在单元格之前(此时行已经有了数据,单元格也有了数据只是还没有paint出来),所以如果你自己给单元格的值(自己paint),必须将e.Handled设置为true;
Examples
The following code demonstrates how to use theCustomDrawCellevent to set up the appearance of"UnitsInStock"column cells. If a cell belongs
to the focused row, custom draw is not applied and the cell is drawn by default. Otherwise the background of a cell is drawn according to its value.
Also we do not perform custom painting of a cell if the"Discontinued"column cell of the same row is checked. Instead, we just change theDisplayTextparameter
to "Discontinued" and leave theHandledparameter set tofalse. This text will be drawn using the default appearance settings after performing the event handler.
If a value of the"Discontinued"column is set tofalse, the background of the"UnitsInStock"cell of the same
row is drawn using theLightSkyBlueor"LightGreen"color according to the cell value. In ths case, theHandledparameter is set
totruein order to prevent default cell painting.
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.Base;
private void advBandedGridView1_CustomDrawCell(object sender, RowCellCustomDrawEventArgs e) {
GridView currentView = sender as GridView;
if(e.RowHandle == currentView.FocusedRowHandle) return;
Rectangle r = e.Bounds;
if(e.Column.FieldName == "UnitsInStock") {
bool check = (bool)currentView.GetRowCellValue(e.RowHandle,
currentView.Columns["Discontinued"]);
if(check) {
//Change the text to display
//The e.Handled parameter is false
//So the cell will be painted using the default appearance settings
e.DisplayText = "Discontinued";
}
else {
// If the cell value is greater then 50 the paint color is LightGreen,
// otherwise LightSkyBlue
Brush ellipseBrush = Brushes.LightSkyBlue;
if (Convert.ToInt16(e.CellValue) > 50) ellipseBrush = Brushes.LightGreen;
//Draw an ellipse within the cell
e.Graphics.FillEllipse(ellipseBrush, r);
r.Width -= 12;
//Draw the cell value
e.Appearance.DrawString(e.Cache, e.DisplayText, r);
//Set e.Handled to true to prevent default painting
e.Handled = true;
}
}
}
分享到:
相关推荐
DevExpress.Web.ASPxGridView.v8.1.dll
或者是从长按事件中开始并初始化一个item拖动对象gridView.startEditMode(position);停止拖动gridView.stopEditMode();添加拖动的ListenergridView.setOnDropListener(new DynamicGridView.OnDropListener(){ @...
重点是ListView事件处理,OnItemClickListener 如果和上下文菜单关联,点上下文菜单去操作item项 要在OnContextItemSelected方法里面得到 AdapterMenuInfo的对象,才能得到你选择的item的下标 有了这个下标就可以...
GridView.zip
if (gridView.Rows.Count || cols > gridView.Rows[0].Cells.Count - 1) { return; } TableCell oldTc = gridView.Rows[0].Cells[cols]; //SO LINE TableCell oldTc12 = gridView.Rows[0].Cells[13]; //No ...
Android_API_中文_(15)_——_GridView.doc Android_API_中文_(15)_——_GridView.doc
可添加、拖动的GridView.zip,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。
AndroidStaggeredGrid允许非对齐行的GridView.zip,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。
智能家居系统 网格视图GridView.doc 学习资料 复习资料 教学资源
Android仿zaker效果demo不使用用gridview.zip
分页的GridView .rar,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。
列可拖动的GridView.zip,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。
仿zaker效果demo不使用用gridview.zip
数据绑定控件—GridView控件.ppt
HorizontalGridView可收缩_分页ViewPager_GridView.zip,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。
一个带动画效果的GridView.rar,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。
GridView 是一个网格布局的列组件。GridView 继承至 CustomScrollView,有 CustomScrollView 的特性。
Aspnet-bootstrap_pagination_gridview.zip,gridview的引导分页,asp.net是一个开源的web框架,用于使用.net构建现代web应用和服务。asp.net创建基于html5、css和javascript的网站,这些网站简单、快速,可以扩展到数...
支付宝钱包首页中带有分割线的GridView.rar,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。
深入挖掘ASP.NET 2.0系列课程(1):随心所欲的使用GridView.zip