根据条件设置cxgrid背景颜色
本文由 猛 于 2016-12-28 9:17 发布在 Delphi
//列颜色【固定列】
if AViewInfo.Item.Caption='序号' then
begin
if AViewInfo.GridRecord.Values[GRDTVJHColumn1.Index]=1 then
begin
ACanvas.Canvas.brush.Color := clRed;
End
else
if AViewInfo.GridRecord.Values[GRDTVJHColumn1.Index]=2 then
begin
ACanvas.Canvas.brush.Color := clGreen;
end
else
if AViewInfo.GridRecord.Values[GRDTVJHColumn1.Index]=3 then
begin
ACanvas.Canvas.brush.Color :=cxstylh.Color;
end;
end;
//列颜色【动态列】
if AViewInfo.Item.Caption='是否合格' then
begin
if (trim(VarToStrDef(AViewInfo.RecordViewInfo.GridRecord.Values[GRDTVSEL.GetColumnByFieldName('是否合格').Index],'')) = '不合格') then
begin
ACanvas.Canvas.brush.Color :=clRed;
ACanvas.Canvas.Font.Color :=clBlue;
end;
end;
//单元格小于0的红色显示
if Pos('-',VarToStr(AViewInfo.GridRecord.Values[AViewInfo.Item.Index]))>0 then
begin
ACanvas.Canvas.Brush.Color:=clRed;
ACanvas.FillRect(AViewInfo.Bounds);
end;