如何尽快将大量字符串加载到MFC组合框控件中? [英] How to load a large array of strings in to an MFC combobox control fast as possible?

查看:176
本文介绍了如何尽快将大量字符串加载到MFC组合框控件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有1000个字符串的数组要加载到组合框中.将字符串数组加载到组合框中的最快方法是什么?

I have an array of 1000 strings to load into a combo box. What is the fastest way to load the array of strings into the combo box?

除了遍历字符串列表之外,还有其他方法可以一次将每个字符串放入组合框吗?

Is there some way other than iterating over the list of strings, putting each string into the combo box one at a time?

一旦加载到其他10个组合框中,如何将组合框中的数据复制?

And how to copy the combo box data once loaded to some 10 other combo boxes?

推荐答案

如果您在10个组合框中重复了1,000个字符串,则可能要考虑使用所有者绘制的组合框,该组合框根据索引动态地绘制字符串.数组,而不是完全将它们存储在组合框中.速度更快,内存效率更高.在联机帮助中查看 DrawItem 方法和 DRAWITEMSTRUCT 结构.基本上,您会做一些事情,例如使用 InitStorage InsertString (如NuSonic所述)在您的combobx中创建1000个空白项目,并覆盖 DrawItem 根据需要提取并绘制所需的基于索引的字符串.

If you have 1,000 strings repeated in 10 comboboxes, you may want to consider using an owner drawn combobox, which draws the strings on the fly based on indices into your array, rather than storing them in the combobox at all. Way faster, way more memory efficient. Check out the DrawItem method and DRAWITEMSTRUCT structure in the on-line help. Basically, you would do something like using InitStorage and InsertString (as mentioned by NuSonic) to create your 1000 blank items in your combobx, and override DrawItem to extract and draw the required string, based on index, as it needs to be drawn.

这篇关于如何尽快将大量字符串加载到MFC组合框控件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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