小弟现在在公司里没有书看没有资料查只能请教各位了:拖了一个LISTBOX,ID为IDC_LST_ITEMS,指定变量名叫做m_sItems,对其基本使用我一点都不了解,希望能给出一些示例代码谢谢!比如怎么添加, 在指定条目后添加,怎么删除一条,
当前条目怎么访问,
指定的变量m_sItems怎么使用等等。
当前条目怎么访问,
指定的变量m_sItems怎么使用等等。
解决方案 »
- VS2008环境下,MFC中多字节与unicode下的ftp连接
- 要写个类似PHOTOSHOP的导航器没思路啊 麻烦进来指点一下
- 只用了列表控件的MFC,VS2008中DEBUG方式编译,对方计算机运行提示配置不正确??
- 用非模式对话框实现图像二值化的问题
- 接收编辑框中输入的回车消息和空格消息
- 收到了HP发来的面试邀请,散点小分涨rp
- 通过DAO取出的时间型数据如何显示
- IO模式下,关于数据接收的疑问,简单问题,需要澄清一下!!
- 如何将捕捉到的视频转换为 asf 格式的文件??
- 进程间通信的问题?
- xsl:for-each和xsl:when不能同时共存?
- GDI+中字体和GDI中的字体之间的关系问题?
CListBox::GetTextThis method retrieves a string from a list box. The second form of this method fills a CString object with the string text.
int GetText(
int nIndex,
LPTSTR lpszBuffer )
const; void GetText(
int nIndex,
CString& rString )
const; ParametersnIndex
Specifies the zero-based index of the string to be retrieved. lpszBuffer
Points to the buffer that receives the string. The buffer must have sufficient space for the string and a terminating null character. The size of the string can be determined ahead of time by calling the GetTextLen method. rString
Specifies a reference to a CString object. Return Value
Returns the length, in bytes, of the string, excluding the terminating null character. If nIndex does not specify a valid index, the return value is LB_ERR.Example
// Pointer to the myListBox.
extern CListBox* pmyListBox;// Dump all of the items in the list box.
#ifdef _DEBUG
CString str, str2;
int n;
for (int i=0;i < pmyListBox->GetCount();i++)
{
n = pmyListBox->GetTextLen( i );
pmyListBox->GetText( i, str.GetBuffer(n) );
str.ReleaseBuffer(); str2.Format(_T("item %d: %s\r\n"), i, str.GetBuffer(0));
afxDump << str2;
}
#endif返回当前选定的串的索引号
CListBox::GetCurSelThis method retrieves the zero-based index of the currently selected item, if any, in a single-selection list box. GetCurSel should not be called for a multiple-selection list box.int GetCurSel( )
const; Return Value
The zero-based index of the currently selected item. It is LB_ERR if no item is currently selected or if the list box is a multiple-selection list box.
Example
// Pointer to the myListBox.
extern CListBox* pmyListBox;// Select the next item of the currently selected one.
int nIndex = pmyListBox->GetCurSel();
int nCount = pmyListBox->GetCount();
if ((nIndex != LB_ERR) && (nCount > 1))
{
if (++nIndex < nCount)
pmyListBox->SetCurSel(nIndex);
else
pmyListBox->SetCurSel(0);
}