ListBox 得到行数和内容 vc++问题

来源:百度知道 编辑:UC知道 时间:2024/06/11 10:29:29
怎么得到ListBox的列表的长度呢?也就是想得到字段的长度(有多少字段)以及每个字段的内容?

分少给不多!!抱歉!!

首先通过ID获取该ListBox控件的CListBox指针list,然后
int Count = list->GetCount();获取字段个数
然后通过循环
CString str;
for(int index=0; index < Count; index++)
{
list->GetText(index, str);
AfxMessageBox(str);
}
这个例子就是将每个字段的内容以对话框形式输出

使用C/C++,察看windowsx.h中以下宏的使用:
ListBox_GetCount
ListBox_GetTextLen
ListBox_GetText

使用MFC,察看CListBox中以下成员函数的使用:
GetCount
GetTextLen
GetText