VB.net Winforms下拉框数据加载问题
我有一个 VB2005 winforms 应用程序,它将从我的数据库表加载城市数据。这是为了确保用户输入正确的城市拼写,以便收到准确的报价。目前,页面加载时约有 15 万个城市被加载到下拉列表框中。该页面加载大约需要 30-40 秒。
我最初的想法是让用户首先选择状态。然后加载城市值。但用户可以选择返回并请求不同城市/州的报价。
有没有更有效的方法来处理这个问题?
I have a VB2005 winforms application that will loads city data from my database table. This is to ensure that the user enters the correct city spelling, in order to receive an accurate quote. Currently, there are about 150K cities that are being loaded to the dropdown listbox on page load. It takes about 30-40 seconds for that page to load.
My initial thought was to allow the user to select the state first. Then load the city values. But the user has the option of going back and requesting a quote for a different city / state.
Is there a more efficient way to handle this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
报价是基于州和城市名称吗?如果是这样,您的方法听起来不错,但请考虑使用 zip 或 zip/城市名称作为引号。并非每个人都会在您的 150K 列表中找到自己的城市,有些人根本不居住在指定的城市中。
Quotes are based on state and city name? If so, your approach sounds good, but consider basing quotes on zip instead, or zip/city name. Not everyone will find their city in your 150K list, and some don't live in named cities at all.
对于初学者,您可以让BackgroundWorker 或Thread 将后台中的数据加载到数组或列表中。然后,您可以在需要时将此数据传递到组合框。
如果您使用此方法,则必须找到一种不时重新索引字段的方法。
For starters you could have a BackgroundWorker or Thread load the data in the background into an array or list. You'd then pass this data to the comboBox when needed.
If you use this method, you must find a way of reindexing the fields from time to time though.