起步软件技术论坛-X3

 找回密码
 立即注册
搜索
12
返回列表 发新帖
楼主: yt_wxw

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

[复制链接]
发表于 2008-6-19 16:54:13 | 显示全部楼层
楼主是如何处理的?

试试给UnPcDays赋个常量
UnPcDays:=Integer(ThdSysUtils.ServerDate - DsbList.DataSet.FieldByName('BIL_DTE').AsDateTime);
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-6-20 14:45:35 | 显示全部楼层
赋常量后速度有所改善
但仍然不尽人意

你们那边可以测试一下阿,在数据集有几百条数据的情况下,你测试一下,看看效果,明显的晃,一刷一刷的
回复 支持 反对

使用道具 举报

发表于 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;
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-7-7 13:43:48 | 显示全部楼层
呵呵 不是说刷新不出来 就是感觉慢 ok 这个问题就这样吧
回复 支持 反对

使用道具 举报

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

本版积分规则

小黑屋|手机版|Justep Inc.

GMT+8, 2025-7-18 23:40 , Processed in 0.035271 second(s), 13 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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