在列表框中花费更多时间 [英] More time taken in listbox

查看:60
本文介绍了在列表框中花费更多时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VS2005中使用列表框,我在table.item中有4个字段,在listboxitem中仅绑定1个字段,即3000,但是当我在视图单击事件上选择此值的选定值更新它时,如果我有在列表框中只有一项,那么花点时间是为什么呢?当我的列表有3000条记录时,我会为此做些什么,并且在更新模式下花点时间.

I am using listbox in VS2005 i have 4 feilds in table.i am bind only 1 feild in listboxitem is 3000 but when i update it on the selected value for select this on the view click event it takes more time if i have in listbox only one item then it''s takes small bit time why ?. what i do for this when my list has 3000 record is maintain and it take samll bit time on update mode.

推荐答案

首先,我想这都是WinForms(不是ASP.NET或其他任何东西,尽管问题可能相似).

我认为您是说,如果只用一个项目填充一个列表框,它很快,但是如果您需要用3,000个项目填充它,那是非常慢的.

在某种程度上这是不可避免的,唯一的办法就是重新设计您正在做的事情,以便列表框中的项目数量减少.

我偶尔会碰到它,并倾向于在列表第一次出现时就使用它-但是对任何更新/更改都进行了手动控制,以使它在表单上的每次更改后都不会从头开始填充-我只是添加/删除任何已更改的项目(如果要进行的更改很少,那么很快.).

另外,您可能想检查一下您要绑定的内容是否不会减慢速度-例如如果要绑定到基础数据库查询,是否已向表中添加适当的索引以确保查询快速运行?

希望这会有所帮助.
First, I presume this is all in WinForms (not ASP.NET or anything else, though the issues might be similar).

I think you are saying that if you populate a list box with one item only it is quick, but if you need to populate it with 3,000 items it is very slow.

To a certain extent that is inevitable and the only way round it is to redesign what you are doing so that you have a smaller number of items in your list box.

I occasionally hit this and tend to live with it the FIRST time a list is populated - but then take manual control over any updates / changes so that it isn''t repopulated from scratch after every change on a form - I just add / remove any items that have changed (which is then quick if there have been few changes to make).

Alternatively, you might want to check that whatever you are binding to isn''t slowing things down - e.g. if you are binding to an underlying database query, have you added appropriate indices to your tables to ensure that the query runs fast?

Hope this helps.


这篇关于在列表框中花费更多时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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