根据条件设置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;

最新评论
网站管理  |  赵猛的个人主页  |  手机版  |  RSS  |  留言建议  |  关于本站  |  联系方式

All Rights Reserved. Powered by emlog Themes by 大智若愚
网站备案号:苏ICP备15011688号-1