单元格变色

在GridView中的gridView_RowCellStyle事件中写代码逻辑,一定要加列名判断。如果不加列名判断,好像整行变色或者是没有效果。具体不记得了

1 if(e.Column.FiledName="XXX") //xxxx为需要变色的那一列绑定的字段名
2 {
3 DataRow dr = gridView2.GetDataRow(e.RowHandle);
4 string value= dr["XXX"].ToString().Trim();//获取单元格数据
5 //add change cell backcolor code
6 e.Appearance.BackColor=Color.Red;//使其变色的关键代码
7 }
View Code

相关文章:

  • 2021-09-29
  • 2021-11-13
  • 2022-12-23
  • 2022-02-02
  • 2022-12-23
  • 2022-02-27
  • 2021-11-29
  • 2022-02-05
猜你喜欢
  • 2022-12-23
  • 2021-07-01
  • 2021-12-23
  • 2021-10-22
  • 2021-12-12
  • 2022-12-23
相关资源
相似解决方案