举例说明DBGrid中行列颜色显示:
纵向斑马线效果:实现网格的奇数列和偶数列分别以不同的颜色显示,以区别相邻的数据列。 file://在DbGrid的DrawColumnCell事件中编写如下代码:
Case DataCol Mod 2 = 0 of
True: DbGrid1.Canvas.Brush.Color:= clBlue; file://偶数列用蓝色
False: DbGrid1.Canvas.Brush.Color:= clAqua; file://奇数列用浅绿色
End;
DbGrid1.Canvas.Pen.Mode:=pmMask;
DbGrid1.DefaultDrawColumnCell (Rect, DataCol, Column, State);