DevExpress的GridView中的行(row)根据条件变色,选中不覆盖整行原本颜色

您所在的位置:网站首页 ae如何变色 DevExpress的GridView中的行(row)根据条件变色,选中不覆盖整行原本颜色

DevExpress的GridView中的行(row)根据条件变色,选中不覆盖整行原本颜色

2023-06-15 18:34| 来源: 网络整理| 查看: 265

效果如下图:

1.找到要变色的dev下的gridview,添加行CHARGE_INDICATOR,当CHARGE_INDICATOR=2时默认为红色。

2.为改行添加gridView1_RowStyle

添加代码如下,运行起来即可

/// /// 设置变色行 /// /// /// private void gridView1_RowStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e) { gridView1.OptionsSelection.EnableAppearanceFocusedRow = false;//默认选中行不变色 gridView1.OptionsSelection.EnableAppearanceFocusedCell = false;//默认选中单元格不变色 if (e.RowHandle>=0) { string postIs = gridView1.GetRowCellDisplayText(e.RowHandle, gridView1.Columns["CHARGE_INDICATOR"]);//获取限制变色条件行的值 if (postIs=="2") { e.Appearance.BackColor = Color.Red;//设置满足条件行背景色为红色 } } }

 

 



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3