分享

Cxgrid单元格颜色显示

 工厂应用 2018-04-12
//表格单元格/行颜色变更
procedure TForm1.cxgrdbtblvw_TestSqueCustomDrawCell(
  Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
  AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
var
   ARec: TRect;
begin
  //单元格变化
    if (AViewInfo.GridRecord.Values[AViewInfo.Item.Index]='Pass') then
    begin
      ACanvas.Canvas.brush.Color := clGreen;
      ACanvas.FillRect(AViewInfo.Bounds);
    end;
  //行变化
  if AViewInfo.RecordViewInfo.GridRecord.Values[cxgrdbclmn_TestSque_Result.Index]='Pass' then
  begin
     ARec := AViewInfo.Bounds;
     ACanvas.canvas.brush.color:= clGreen;
     ACanvas.FillRect(ARec);
  end;
  if AViewInfo.RecordViewInfo.GridRecord.Values[cxgrdbclmn_TestSque_Result.Index]='Fail' then
  begin
    ARec := AViewInfo.Bounds;
    ACanvas.Brush.Color:= clRed;
    ACanvas.FillRect(ARec);
  end;
  if AViewInfo.RecordViewInfo.GridRecord.Values[cxgrdbclmn_TestSque_Result.Index]='Testing' then
  begin
    ARec := AViewInfo.Bounds;
    ACanvas.Brush.Color:= clOlive;
    ACanvas.FillRect(ARec);
  end;
  if AViewInfo.RecordViewInfo.GridRecord.Values[cxgrdbclmn_TestSque_Result.Index] ='' then
  begin
    ARec := AViewInfo.Bounds;
    ACanvas.Brush.Color:= clMoneyGreen;
    ACanvas.FillRect(ARec);
  end;
end;

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多