gridview设置单元格颜色

266 阅读1分钟

DEV Express gridview设置单元格颜色 设置奇偶行颜色

1.RowCellStyle事件

private void gridView1_RowCellStyle(objectsender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e) { if (e.RowHandle == 2 && e.Column.FieldName == "1") { e.Appearance.ForeColor = Color.Red;//改变字体颜色 e.Appearance.BackColor = Color.DarkGray;//改变背景颜色 } }

RowHandle 行 从0开始 column.FieldName 列名

2.设置奇偶行颜色

this.gridView1.Appearance.OddRow.BackColor = Color.Pink; // 设置奇数行颜色 this.gridView1.OptionsView.EnableAppearanceOddRow = true; // 和上面绑定 同时使用有效

this.gridView1.Appearance.EvenRow.BackColor = Color.GreenYellow; // 设置偶数行颜色 this.gridView1.OptionsView.EnableAppearanceEvenRow = true; //和上面绑定 同时使用有效