如何从组合框中获取打印项目 [英] How to get typped item from a combo box

查看:88
本文介绍了如何从组合框中获取打印项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我是vc ++的新手。我认为我有一个对话框,它包含CombBox。

假设用户在ComboBox中打了一个新字符串。键入后单击一个按钮。然后如何从该梳理盒中获取该类型的单词?

Hi,
iam new to vc++. consider i have a dialog box and it contain CombBox.
suppose user typped a new string in ComboBox. After typed a button is clicked. then how to get that typed word from that comb box?

推荐答案

使用MFC(CComboBox)您可以轻松调用 CComboBox :: GetLBText(),使用 CComboBox :: GetCurSel()
Using MFC (CComboBox) you can easy call CComboBox::GetLBText(), passing it the current selection using CComboBox::GetCurSel()


引用当前选择> Quote:
Quote:

但是上面的代码不起作用。实际输入字符串是不是处于选定模式然后如何给索引?我使用AutoComplete组合框。所以我需要来自用户的打字输入。

But the above code does''nt work. actually input string is not in selected mode then how it give index? iam using an AutoComplete combo box. so i need typed input from user.



如果你需要获得与之相关的文字?然后使用GetWindowtext()。

例如:


If you need to get text associated with it? then use GetWindowtext().
eg:

CString csText;
m_Combo.GetWindowText( csText );


如果您使用的是MFC,在尝试查看之前不要忘记执行UpdateData()在控件的内容。
If you are using MFC, don''t forget to do UpdateData() before you try to look at the control''s contents.


这篇关于如何从组合框中获取打印项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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