- 下面为在CxGrid的CustomDrawCell的代码
- procedure TForm1.cxGrid1DBTableView1CustomDrawCell(
- Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
- AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
- var
- vStr:string;
- begin
- vStr:=Trim(VarAsType(AViewInfo.GridRecord.DisplayTexts[cxGrid1DBTableView1Column3.Index],varString));
- if vStr='A' then
- begin
- ACanvas.Canvas.Brush.Color :=clred;
- ACanvas.canvas.Font.Color :=clblack;
- end
- else if vStr='B' then
- begin
- ACanvas.Canvas.Brush.Color :=clgreen;
- ACanvas.canvas.Font.Color :=clblack;
- end
- else if vStr='C' then
- begin
- ACanvas.Canvas.Brush.Color :=clYellow;
- ACanvas.canvas.Font.Color :=clblack;
- end;
- if AViewInfo.Selected then
- begin
- ACanvas.Canvas.Font.Color :=clwhite;
- ACanvas.Canvas.Brush.Color :=clNavy;
- end;
- end;