Stringgrid隔行换颜色
如题:
stringgrid隔行显示不同颜色。
代码怎么写?
[解决办法]
在StringGrid控件的OnDrawCell事件中添加如下代码
if (ARow mod 2)=0 then
begin
if not (gdSelected in State) then//用来表示在选中的时候,显示不同的颜色,如果不要求选中的时候有不同的颜色,可直接去掉
begin
self.strngrd1.Canvas.Brush.Color:=clred;
Self.strngrd1.Canvas.FillRect(Rect);
end;
end
else
begin
if not (gdSelected in State) then
begin
self.strngrd1.Canvas.Brush.Color:=clBlue;
Self.strngrd1.Canvas.FillRect(Rect);
end;
end;