在MFC VC ++中连接列表框和文本框 [英] Connect listbox and text box in MFC VC++

查看:92
本文介绍了在MFC VC ++中连接列表框和文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用CString方法,但它不足以添加100个项目..请建议一些方法/代码/电子书

Im using CString method but its not enough to add 100 items..Please suggest some methods/Codes/Ebooks

推荐答案

CString是一个MFC类,持有一个字符串。

CListBox控件类用于显示用户可以选择的字符串列表。

CEdit控件类用于显示和编辑文本。它可以设置为单行或多行模式。



为了向CListBox对象添加字符串,可以调用CListBo :: AddString()方法。

例如,如果你想在列表框中添加三个项目text1,text2和text3,你可以编写这段代码:

CString is a MFC class that holds a string of chars.
The CListBox control class is used to display a list of strings that the user can choose from.
The CEdit control class is used to display and edit text. It can be set to single line or multiline mode.

In order to add strings to CListBox object you call the CListBo::AddString() method.
For example if you want to add three items "text1", "text2" and "text3" to the list box, you can write this code:
CListBox m_listBox; 
m_listBox.AddString(_T("text1"));
m_listBox.AddString(_T("text2"));
m_listBox.AddString(_T("text3"));



如果需要将文本设置为CEdit对象,可以调用CEdi :: SetWindowText( )方法。

例如:


If you need to set a text to CEdit object you can call the CEdi::SetWindowText() method.
For example:

CEdit m_editCtrl;
m_editCtrl.SetWindowText(_T("text3"));



希望它有所帮助。

您需要更加具体描述你想要做什么。


Hope it helps.
You need to be more specific in describing what you are trying to do.


这篇关于在MFC VC ++中连接列表框和文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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