cxgrid改变选中行颜色

procedure Tfrm_select_case_model_other.dw_1CustomDrawCell(
 Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
 AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
var
  ARec: TRect;
begin
 if AViewInfo.Focused then
 begin
   ARec := AViewInfo.Bounds;
   ACanvas.canvas.brush.color:= clSkyBlue;
   ACanvas.Font.Color := clRed;
   ACanvas.FillRect(ARec);
 end
 else
 begin
   ARec := AViewInfo.Bounds;
   ACanvas.canvas.brush.color:= clWhite;
   ACanvas.Font.Color := clBlack;
   ACanvas.FillRect(ARec);
 end;

end;


var
  ARec: TRect;
  i:integer;
begin
  if AViewInfo.Focused then
  begin
   ARec := AViewInfo.Bounds;
   ACanvas.canvas.brush.color:= clSkyBlue;
   ACanvas.Font.Color := clRed;
   ACanvas.FillRect(ARec);
  end
  else
  begin
   ARec := AViewInfo.Bounds;
   ACanvas.canvas.brush.color:= clWhite;
   ACanvas.Font.Color := clBlack;
   ACanvas.FillRect(ARec);
  end;
  if (AViewInfo.Item.Index = 18) or (AViewInfo.Item.Index = 19) or
    (AViewInfo.Item.Index = 33) or (AViewInfo.Item.Index = 34) or
    (AViewInfo.Item.Index = 48) or (AViewInfo.Item.Index = 49) then
  begin
    ARec := AViewInfo.Bounds;
    ACanvas.canvas.brush.color:= clSkyBlue;
    ACanvas.FillRect(ARec);
  end;
  if (AViewInfo.Item.Index >= 6) and (AViewInfo.Item.Index <= 19) then
  for i := 6 to 19 do
  begin
    if vartostr(AViewInfo.RecordViewInfo.GridRecord.Values[i])= '-' then
    begin
      ARec := AViewInfo.Bounds;
      ACanvas.Font.Color := clRed;
      ACanvas.FillRect(ARec);
    end;
  end;
  if (AViewInfo.Item.Index >= 21) and (AViewInfo.Item.Index <= 34) then
  for i := 21 to 34 do
  begin
    if vartostr(AViewInfo.RecordViewInfo.GridRecord.Values[i]) = '-' then
    begin
      ARec := AViewInfo.Bounds;
      ACanvas.Font.Color := clRed;
      ACanvas.FillRect(ARec);
    end;
  end;

你可能感兴趣的:(字体,颜色,cxgrid)