5,388
社区成员
发帖
与我相关
我的任务
分享
procedure TYinDangBiao.cxGrid1DBBandedTableView1CustomDrawCell(
Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
begin
if (AViewInfo.GridRecord.Values[cxGrid1DBBandedTableView1.GetColumnByFieldName('pds').Index] < AViewInfo.GridRecord.Values[cxGrid1DBBandedTableView1.GetColumnByFieldName('njzzk').Index]) and (AViewInfo.Item.ID = 8) then
ACanvas.Canvas.Font.Color := clRed
else if (AViewInfo.GridRecord.Values[cxGrid1DBBandedTableView1.GetColumnByFieldName('nzk').Index] < AViewInfo.GridRecord.Values[cxGrid1DBBandedTableView1.GetColumnByFieldName('n1jzzk').Index]) and (AViewInfo.Item.ID = 14) then
ACanvas.Canvas.Font.Color := clRed
else if (AViewInfo.GridRecord.Values[cxGrid1DBBandedTableView1.GetColumnByFieldName('n1zk').Index] < AViewInfo.GridRecord.Values[cxGrid1DBBandedTableView1.GetColumnByFieldName('n2jzzk').Index]) and (AViewInfo.Item.ID = 19) then
ACanvas.Canvas.Font.Color := clRed
else if (AViewInfo.GridRecord.Values[cxGrid1DBBandedTableView1.GetColumnByFieldName('n2zk').Index] < AViewInfo.GridRecord.Values[cxGrid1DBBandedTableView1.GetColumnByFieldName('n3jzzk').Index]) and (AViewInfo.Item.ID = 24) then
ACanvas.Canvas.Font.Color := clRed;
end;
procedure TForm1.cxGrid1DBTableView1StylesGetContentStyle(
Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
var i:integer;
begin
if AItem=nil then exit;
case AItem.Index of
1: i := 0; //A列为0,B列为1
5: i := 3; //F列为5,D列为3
9: i := 6; //J列为9,G列为6
22: i := 12; //W列为22,M列为12
else
exit;
end;
if ARecord.Values[AItem.Index]>ARecord.Values[i] then//如果该记录的当前列的值大于参照列的值
AStyle.Color:=clRed//用红底色显示
else
AStyle.Color:=clWindow; //用白底色显示
end;