下列代码演示了如何使用 RowCellStyle 事件处理程序来定制个别网格单元格的外观。 在本例中,以交错方式对网格单元格着色。
下面的插图展示了运行结果:
C# | 复制代码 |
---|
using DevExpress.XtraGrid.Views.Grid;
private void gridView1_RowCellStyle(object sender, RowCellStyleEventArgs e) {
if(e.RowHandle != gridView1.FocusedRowHandle &&
((e.RowHandle % 2 == 0 && e.Column.VisibleIndex % 2 == 1) ||
(e.Column.VisibleIndex % 2 == 0 && e.RowHandle % 2 == 1)))
e.Appearance.BackColor = Color.NavajoWhite;
}
|
Visual Basic | 复制代码 |
---|
Imports DevExpress.XtraGrid.Views.Grid
Private Sub gridView1_RowCellStyle(ByVal sender As Object, _
ByVal e As RowCellStyleEventArgs) Handles gridView1.RowCellStyle
If e.RowHandle <> gridView1.FocusedRowHandle And _
((e.RowHandle Mod 2 = 0 And e.Column.VisibleIndex Mod 2 = 1) Or _
(e.Column.VisibleIndex Mod 2 = 0 And e.RowHandle Mod 2 = 1)) Then _
e.Appearance.BackColor = Color.NavajoWhite
End Sub
|