DataGrid的DataGridCustomDrawCell事件中加入如下代码,用以根据条件变换行的颜色,可是Grid的数据记录有个几十行的时候就会明显感觉到Grid的刷新速度太慢,有点像放慢动作,而同样的代码在Delphi中则不存在此问题,这样慢的刷新速度给客户的感觉不好,好像是系统很慢似的。请问怎么个问题?
procedure TCARGO_LIST.DataGridCustomDrawCell(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;
begin
Inherited;
if DsbList.DataSet.Group.KeyFieldNames<>'' then exit;
if (DsbList.DataSet.Active) and (DsbList.DataSet.FieldByName('PC_ID').Asstring='F') then
begin
UnPcDays:=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;