|
发表于 2008-6-20 15:11:49
|
显示全部楼层
楼主,我用你的代码测试过了(只把UnPcDays赋了常量),取100条数据,速度还可以的,不到1秒就可以刷新完成。
procedure TMainForm.DataGrid1CustomDrawCell(Sender: TObject; ACanvas: TCanvas;
ARect: TRect; ANode: TTreeListNode; AColumn: TTreeListColumn; ASelected,
AFocused, ANewItemRow: Boolean; var AText: string; var AColor: Integer;
AFont: TFont; var AAlignment: TAlignment; var ADone: Boolean);
var
UnPcDays:Integer;
DsbList: TDataSource;
begin
Inherited;
DsbList := TDataGrid(Sender).DataSource;
if TSqlDataSet(DsbList.DataSet).Group.KeyFieldNames<>'' then exit;
if (DsbList.DataSet.Active) {and (DsbList.DataSet.FieldByName('PC_ID').Asstring='F')} then
begin
UnPcDays:= 10;//Integer(ThdSysUtils.ServerDate - DsbList.DataSet.FieldByName('BIL_DTE').AsDateTime);
if ASelected or AFocused then
begin
end
else
begin
if (UnPcDays>=5) and (UnPcDays<7) then
begin
AColor:=Business.System.Graphics.clYellow;
end
else if (UnPcDays>=7) and (UnPcDays<10) then
begin
AColor:=Business.System.Graphics.clBlue;
end
else if (UnPcDays>=10)then
begin
AColor:=Business.System.Graphics.clRed;
end;
end;
end;
end; |
|