Devexpress按单元格值控制整行或单个单元格颜色
发布时间
阅读量:
阅读量
需求:实现价格列表的动态展示功能,根据设定规则,价格上涨时以红色呈现,价格下跌时以绿色呈现,其余情况则采用黑色显示。
由于采用了自定义控件,还需对GridView相关事件进行定义:
- 根据单元格中UpDown列的数值变化,调整整行数据的显示颜色
1.1 自定义事件:
private void frmPriceManage_Load(object sender, EventArgs e)
{
ucGrid1.UcGridView.RowCellStyle += UcGridView_RowCellStyle;
}
1.2 事件编码
private void UcGridView_RowCellStyle(object sender, RowCellStyleEventArgs e)
{
/// 取GridView单元格值,并根据该值影响单元格的颜色
decimal.TryParse(ucGrid1.UcGridView.GetRowCellValue(e.RowHandle, "UpDown").ToString(), out decimal vUpDown);
全部评论 (0)
还没有任何评论哟~
