起步软件技术论坛-X3

 找回密码
 立即注册
搜索
查看: 276|回复: 13

【结帖】DataGrid刷新速度慢**

[复制链接]
发表于 2008-5-22 18:51:56 | 显示全部楼层 |阅读模式
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;
回复

使用道具 举报

发表于 2008-5-23 08:59:19 | 显示全部楼层
这个好像没有什么好办法,跟数据量有关。
回复 支持 反对

使用道具 举报

发表于 2008-5-23 09:03:52 | 显示全部楼层
楼主,注释掉这些代码后,速度会变快吗?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-5-26 18:19:42 | 显示全部楼层
to jiahaiming
是的
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-5-26 18:21:08 | 显示全部楼层
to lisb
几十条数据也算数据量?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-6-13 17:08:54 | 显示全部楼层
回复 支持 反对

使用道具 举报

发表于 2008-6-13 18:38:01 | 显示全部楼层
楼主,请问刷新的速度有多慢?
回复 支持 反对

使用道具 举报

发表于 2008-6-13 18:38:47 | 显示全部楼层
似乎与代码有些关系。
回复 支持 反对

使用道具 举报

发表于 2008-6-18 11:35:40 | 显示全部楼层
楼主,问题怎么样了?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-6-19 15:53:08 | 显示全部楼层
还是老样子
代码中的ThdSysUtils.ServerDate似乎占用一定时间,但处理后还是慢
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Justep Inc.

GMT+8, 2025-7-18 23:35 , Processed in 0.040807 second(s), 15 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表