使用大量数据填充组合框的最快方法 [英] Fastest Way of Populating Combobox With Large Amount Of Data

查看:74
本文介绍了使用大量数据填充组合框的最快方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个数据库应用程序,我必须从数据库中将大约一千个项目列表加载到一个组合框中。使用

I am writing a database application in which i have to load about a thousand list of items from the database into a combobox. The retrieving and the population of the data into the combobox is done successfully using the

foreach

循环成功完成了对组合框中数据的检索和填充。但问题是,由于需要填充大量项目,因此组合框的填充需要很长时间才能完成。



任何民间帮助我想知道如何以最快的方式填充组合框?我将非常感谢。谢谢。

loop. But the problem is that it takes too long a time for the populating of the combobox to get completed because of the large list of items to populate.

Can any folk help me with an idea about how to populate the combobox in the fastest way possible? I will be very thankful for that. Thank you.

推荐答案

一次只能将数据显式加载到一个项目的组合框中,为什么一旦你没有将数据绑定到它检索它。这通常效率更高。



但是,是否有理由需要显示那么多项目。根据我的经验,用户不会想要通过那么多项来找到他们想要的东西。而不是加载1000个项目,为什么不提供自动完成?
Rather than explicitly loading the data into the combo box an item at a time, why don't you bind the data to it once you've retrieved it. This is generally a lot more efficient.

However, is there a reason you need to display that many items. In my experience, users will not want to wade through that many items to find one that they want. Rather than loading 1000 items, why not provide AutoComplete instead?


千元不是一个大数字。理想情况下,处理它们不需要很长时间。你确定这是一个需要花费很多时间的循环吗?
Thousand is not a big number. Ideally it should not take long to process them. Are you sure it is the loop that takes so much time?


要么使用 Items.AddRange [ ^ ]同时添加所有项目,或者将循环包装在 BeginUpdate [ ^ ] / EndUpdate。



编辑:但事实上,要放入下拉列表的项目太多,您应该使用自动填写的文本框或类似的东西。
Either use Items.AddRange[^] to add all the items at the same time, or wrap your loop in BeginUpdate[^]/EndUpdate.

but indeed, this is way too many items to put in a dropdown, you should use an auto-completing textbox or something similar instead.


这篇关于使用大量数据填充组合框的最快方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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