添加大量项目时,列表框会变慢 [英] Listbox slows down when adding large number of items

查看:73
本文介绍了添加大量项目时,列表框会变慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我有一个列表框,我添加了简单的STRING项目 - 我有一个

进度条,每当我填充

完整集的另一部分时,我会增加我希望添加的项目。我观察到的是,随着越来越多的元素被添加,列表框的填充越来越长。即第一个

项目集的第10个比第10个快得多。这是大约40,000个列表框项目的
。我担心的是列表框可以

有效存储1000多件物品中的100件。


这是标准列表框的已知功能。我真的想使用

列表框控件,因为它提供了我需要的完美功能。只是

好​​奇(担心)关于半指数增加的itel Add()时间。


非常感谢。


-

通过DotNetMonster.com发布的消息
http://www.dotnetmonster.com/Uwe/For...sharp/200606/1

Basically I have a listbox to which I add simple STRING items- I have a
progress bar which I increment whenever I populate another portion of the
complete set of items I wish to add. What I observe is that as more and more
are added, population of the list box takes longer and longer. ie the first
10th of the item set are added much much quicker than the last 10th. THis
occurs with about 40,000 listbox items. My worry is the listbox may
potenetially store many 100s of 1000s of items.

Is this a known feature of the standard listbox. I really want to use a
listbox control as it offers perfect functionality for what I need. Just
curious (worried) about the semi-exponentially increasing itel Add () time.

Many thanks.

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...sharp/200606/1

推荐答案

尝试使用BeginUpdate / EndUpdate方法来查看是否有助于确定你的情况。


-

Tim Wilson

..NET Compact Framework MVP


新闻:617a7b393a0bc @ uwe ...
Try using the BeginUpdate/EndUpdate methods to see if that helps perf in
your situation.

--
Tim Wilson
..NET Compact Framework MVP

"Paul_Madden via DotNetMonster.com" <u21795@uwe> wrote in message
news:617a7b393a0bc@uwe...
基本上我有一个列表框,我添加了简单的STRING项目 - 我有一个
进度条每当我填充我希望添加的完整项目集的另一部分时,我会递增。我观察到的是,随着更多和更多
的添加,列表框的填充时间越来越长。即项目集的第一个第10个比第10个更快地添加。这有大约40,000个列表框项目。我担心的是列表框可以有效地存储1000多件物品中的100件。

这是标准列表框的已知功能。我真的想使用
列表框控件,因为它提供了我需要的完美功能。只是好奇(担心)关于半指数增加的itel Add()
时间。

非常感谢。

-
通过DotNetMonster.com发布的消息
http://www.dotnetmonster.com/Uwe/For...sharp/200606/1
Basically I have a listbox to which I add simple STRING items- I have a
progress bar which I increment whenever I populate another portion of the
complete set of items I wish to add. What I observe is that as more and
more
are added, population of the list box takes longer and longer. ie the
first
10th of the item set are added much much quicker than the last 10th. THis
occurs with about 40,000 listbox items. My worry is the listbox may
potenetially store many 100s of 1000s of items.

Is this a known feature of the standard listbox. I really want to use a
listbox control as it offers perfect functionality for what I need. Just
curious (worried) about the semi-exponentially increasing itel Add ()
time.

Many thanks.

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...sharp/200606/1



Paul:

列表框中的40,000项?你一定要开个玩笑,伙计!为什么不给你

用typeahead设置一些东西,输入前几个字母设置一个

Sql调用


WHERE xYZ LIKE''+ searchterm +''%''


然后只需带回相应的物品?


Peter


-

联合创始人,Eggheadcafe.com开发者门户网站:
http://www.eggheadcafe.com

UnBlog:
http://petesbloggerama.blogspot.com


" Paul_Madden via DotNetMonster.com"写道:
Paul:
40,000 items in a Listbox? You have got to be kidding, man! Why don''t you
set something up with typeahead where the first few letters typed set up a
Sql call with

WHERE xyz LIKE '' +searchterm +''%''

and then just bring back the matching items?

Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Paul_Madden via DotNetMonster.com" wrote:
基本上我有一个列表框,我添加简单的STRING项目 - 我有一个
进度条,每当我填充
的另一部分时我会增加我希望添加的完整项目集。我观察到的是,随着越来越多的添加,列表框的填充越来越长。即项目集的第一个第10个比第10个更快地添加。这有大约40,000个列表框项目。我担心的是列表框可以有效地存储1000多件物品中的100件。

这是标准列表框的已知功能。我真的想使用
列表框控件,因为它提供了我需要的完美功能。只是好奇(担心)关于半指数增加的itel Add()时间。

非常感谢。

-
通过DotNetMonster发布的消息.com
http:// www.dotnetmonster.com/Uwe/For...sharp/200606/1
Basically I have a listbox to which I add simple STRING items- I have a
progress bar which I increment whenever I populate another portion of the
complete set of items I wish to add. What I observe is that as more and more
are added, population of the list box takes longer and longer. ie the first
10th of the item set are added much much quicker than the last 10th. THis
occurs with about 40,000 listbox items. My worry is the listbox may
potenetially store many 100s of 1000s of items.

Is this a known feature of the standard listbox. I really want to use a
listbox control as it offers perfect functionality for what I need. Just
curious (worried) about the semi-exponentially increasing itel Add () time.

Many thanks.

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...sharp/200606/1



您是否偶然处理排序列表?


如果是这样的话,我完全可以期待它是O(log n)(做二进制搜索)只是为了

找出它应该放在哪里和O (n)必须发生的副本

补充:。在找到要插入O(log n)的位置后(二进制搜索)

我希望O(n)操作能够复制每个在数组中传递的操作。

示例...(左侧索引,右侧值)


我的阵列是

0 1

1 3

2 4

3 5

4 6

5 7

插入2 ...


我现在必须复制3-7(将它们移动到一个位置)以腾出空间2


0 1

1?

2 3

3 4

5 6

6 7


然后我把我的价值放在阵列中的第二个位置,最后是


0 1
1 2

2 3

3 4

5 6

6 7
如果是这种情况,您可以通过添加所有

项目,然后使用Sort()方法对它们进行排序来提高效率。这只会对

列表进行一次排序,而不是40k阵列副本:) ...


干杯,


Greg Young

MVP - C#
http:// geekswithblogs .net / gyoung

" Paul_Madden via DotNetMonster.com" < u21795 @乌韦>在消息中写道

新闻:617a7b393a0bc @ uwe ...
Are you by chance dealing with a sorted list?

If so I would fully expect it to be O(log n) (doing binary searches) just to
figure out where it should put it and O(n) for the copy that must occur on
adds :. After the finding of the location to insert O(log n) (binary search)
I would expect an O(n) operation to copy every passed it in the array.

example ... (indexes on left, values on right)

my array is
0 1
1 3
2 4
3 5
4 6
5 7

insert 2 ...

I now have to copy 3-7 (moving them up a spot) to make room for 2

0 1
1 ?
2 3
3 4
5 6
6 7

I then place my value at the second spot in the array ending up with

0 1
1 2
2 3
3 4
5 6
6 7
If this is the case you can make it much more efficient by adding all the
items, then sorting them using the Sort() method. This will only sort the
list once as opposed to 40k array copies :) ...

Cheers,

Greg Young
MVP - C#
http://geekswithblogs.net/gyoung
"Paul_Madden via DotNetMonster.com" <u21795@uwe> wrote in message
news:617a7b393a0bc@uwe...
基本上我有一个列表框,我添加了简单的STRING项目 - 我有一个
进度条每当我填充我希望添加的完整项目集的另一部分时,我会递增。我观察到的是,随着更多和更多
的添加,列表框的填充时间越来越长。即项目集的第一个第10个比第10个更快地添加。这有大约40,000个列表框项目。我担心的是列表框可以有效地存储1000多件物品中的100件。

这是标准列表框的已知功能。我真的想使用
列表框控件,因为它提供了我需要的完美功能。只是好奇(担心)关于半指数增加的itel Add()
时间。

非常感谢。

-
通过DotNetMonster.com发布的消息
http://www.dotnetmonster.com/Uwe/For...sharp/200606/1
Basically I have a listbox to which I add simple STRING items- I have a
progress bar which I increment whenever I populate another portion of the
complete set of items I wish to add. What I observe is that as more and
more
are added, population of the list box takes longer and longer. ie the
first
10th of the item set are added much much quicker than the last 10th. THis
occurs with about 40,000 listbox items. My worry is the listbox may
potenetially store many 100s of 1000s of items.

Is this a known feature of the standard listbox. I really want to use a
listbox control as it offers perfect functionality for what I need. Just
curious (worried) about the semi-exponentially increasing itel Add ()
time.

Many thanks.

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...sharp/200606/1



这篇关于添加大量项目时,列表框会变慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆