用ListView显示数据库中的记录,但是刷新太慢,怎么办? ListView通过数据控件连接oracle数据库,语句写好后直接执行速度很快,并已优化,但是在程序里 ListView显示的时候速度非常慢,基本就是查的快,但是在 ListView上显示的速度太慢,2万条记录大概要30分钟左右,无法忍受,但是用不想用别的控件,请问有什么好的解决方法? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 mylist.Items.BeginUpdate; ... mylist.Items.EndUpdate; 数据在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); 用BeginUpdate和EndUpdate.BeginUpdate; //你的显示程序段EndUpdate; knife_s(人生常恨水常东) , SuanAddMiao(算苗): 这两条代码我已经加上了,但是没有解决问题。 xthmpro_cn() : 我用的是delphi 3 ,没有OnDrawItem属性,我认为你说的“查询数据后不要逐条插入到ListView” 很有道理,ListView.Items.Count:=Dataset.RecordCount设定数量,但是接着再怎么写我就不太清楚了,请指教。 ListView.Items.Count:=Dataset.RecordCount设定数量时 提示:Cannot assign to a read-only property; 请问在何处使这个属性不为只读? BeginUpdate和EndUpdate.没有用用虚拟方法,ondata 你怎么用D3呢,不能使用D5或D6吗?d3我不懂哦. 同意fj218,ondata是比较有效的方式, CSDN文档中心好象有这样的例子, 记得以前看到过。 如何在listbox右键能选定当前行并打开菜单? 请教一个“开料算法” interbase设置和delphi7调试的问题 小妹我刚学delphi,请问该从什么学起? 希望大家提供一个控件! 有关文件压缩传输的Web Service,急用,请帮忙? error loading midas.dll问题 ,先前回复的兄弟,请再回复一次,谢谢,原帖子看不了 怎样去设置这样的字体? 类与函数之间是否有关系 远程抓图,你们试过吗?我试过,不可靠,会出问题!你有高招? 请问大连哪里有卖正版windows的 我想在DBGrid的当前游标下插入一个记录,代码怎么写?
...
mylist.Items.EndUpdate;
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);
BeginUpdate;
//你的显示程序段
EndUpdate;
用虚拟方法,ondata