ListView通过数据控件连接oracle数据库,语句写好后直接执行速度很快,并已优化,但是在程序里 ListView显示的时候速度非常慢,基本就是查的快,但是在 ListView上显示的速度太慢,2万条记录大概要30分钟左右,无法忍受,但是用不想用别的控件,请问有什么好的解决方法?

解决方案 »

  1.   

    mylist.Items.BeginUpdate;
      ...
      mylist.Items.EndUpdate;
      

  2.   

    数据在DataSet中,查询数据后不要逐条插入到ListView,你要用自画的方式来解决这个问题。
    1、ListView.Items.Count:=Dataset.RecordCount
    然后在OnDrawItem事件中自己写代码画.
    Delphi中有例子:
    .\Delphi6\Demos\Virtual Listview
    看看他的:
    procedure TForm1.ListViewDataHint(Sender: TObject; StartIndex,  EndIndex: Integer);
    procedure TForm1.ListViewData(Sender: TObject; Item: TListItem);
    procedure TForm1.ListViewDataFind(Sender: TObject; Find: TItemFind;
      const FindString: String; const FindPosition: TPoint; FindData: Pointer;
      StartIndex: Integer; Direction: TSearchDirection; Wrap: Boolean;
      var Index: Integer);
    procedure TForm1.ListViewCustomDrawItem(Sender: TCustomListView;
      Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
    procedure TForm1.ListViewCustomDrawSubItem(Sender: TCustomListView;
      Item: TListItem; SubItem: Integer; State: TCustomDrawState;
      var DefaultDraw: Boolean);
      

  3.   

    用BeginUpdate和EndUpdate.
    BeginUpdate;
     //你的显示程序段
    EndUpdate;
      

  4.   

    knife_s(人生常恨水常东) , SuanAddMiao(算苗): 这两条代码我已经加上了,但是没有解决问题。 xthmpro_cn() : 我用的是delphi 3 ,没有OnDrawItem属性,我认为你说的“查询数据后不要逐条插入到ListView” 很有道理,ListView.Items.Count:=Dataset.RecordCount设定数量,但是接着再怎么写我就不太清楚了,请指教。
      

  5.   

    ListView.Items.Count:=Dataset.RecordCount设定数量时 提示:Cannot assign to a read-only property;  请问在何处使这个属性不为只读?
      

  6.   

    BeginUpdate和EndUpdate.没有用
    用虚拟方法,ondata
      

  7.   

    你怎么用D3呢,不能使用D5或D6吗?d3我不懂哦.
      

  8.   

    同意fj218,ondata是比较有效的方式, CSDN文档中心好象有这样的例子, 记得以前看到过。