通过CComboBox(MFC)中的文本设置选择 [英] Setting selection by text in CComboBox (MFC)

查看:686
本文介绍了通过CComboBox(MFC)中的文本设置选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类型为DropList的CComboBox(即,它不可编辑).通过字符串设置当前选择的最简单方法是什么?

I have a CComboBox of type DropList (i.e. it's not editable). What's the easiest way to set the current selection by string?

我知道我可以使用SetCurSel()按索引设置它,但是我希望该函数按字符串搜索列表项并进行设置.

I know I can use SetCurSel() to set it by index, but I want the function to search through the list-items by string and set it.

推荐答案

CComboBox :: SelectString怎么样?

What about CComboBox::SelectString ?

在组合框的列表框中搜索一个字符串,如果找到该字符串,则在列表框中选择该字符串并将其复制到编辑控件中."

"Searches for a string in the list box of a combo box, and if the string is found, selects the string in the list box and copies it to the edit control."

https://msdn.microsoft. com/en-us/library/30ft9e54(v = vs.110).aspx

这篇关于通过CComboBox(MFC)中的文本设置选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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