procedure TForm1.cxGrid1DBTableView1CustomDrawCell( Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean); //var // abc:Integer; //整行 var CheckValue:integer; //單元格 cxColumn:TcxGridColumn; //整列 begin { abc:=AViewInfo.GridView.FindItemByName('cxGrid1DBTableView1Column4').Index; if AViewInfo.GridRecord.Values[abc]=True and ((AViewInfo.RecordViewInfo.GridRecord.Values[4])='0') then begin AViewInfo.GridRecord.Values[aa]=True and AViewInfo. ACanvas.Brush.Color:=clRed; end;} cxColumn:=(Sender as TcxGridDBTableView).GetColumnByFieldName('Full_Name');//獲取列 if cxColumn=nil then Exit;
if SameText(AViewInfo.Item.Name,cxColumn.Name) then //限制是否只Paint指定的單元格條件 begin CheckValue:=AViewInfo.GridRecord.Values[cxGrid1DBTableView1Column4.Index]; //獲取單元格條件 if CheckValue>10 then //單元格背景變色條件 begin AViewInfo.Focused; ACanvas.Brush.Color:=clRed; end;
if CheckValue>20 then begin AViewInfo.Focused; ACanvas.Brush.Color:=clGreen; end;
if CheckValue>30 then begin AViewInfo.Focused; ACanvas.Brush.Color:=clBlue; end; end; end;