求 MFC 下拉列表框用到的一个函数

bai532656789 2010-07-08 08:37:22
请问各位大虾,获取下拉列表框里面每一项的函数怎么写?


比方说下拉列表框里面有 1
2
3
4
5


这几个选项我想把他们依次都获取出来
应该是什么函数?
小弟是菜鸟 麻烦各位大虾能尽量给写明白一点,谢拉感激不尽!
...全文
104 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
ForestDB 2010-07-10
  • 打赏
  • 举报
回复
帮顶。
spotatoes 2010-07-10
  • 打赏
  • 举报
回复

//用循环的
for( int i=0; i< combox->GetCount(); i++ )
{
combox->SetCurSel(i);
CString str = combox->GetWindowText();
//str to do sthd;
}


yunyun1886358 2010-07-09
  • 打赏
  • 举报
回复

// Dump all of the items in the combo box.
CString str1, str2;
int n;
for (int i = 0; i < m_pComboBox->GetCount(); i++)
{
n = m_pComboBox->GetLBTextLen(i);
m_pComboBox->GetLBText(i, str1.GetBuffer(n));
str1.ReleaseBuffer();

str2.Format(_T("item %d: %s\r\n"), i, str1.GetBuffer(0));
AFXDUMP(str2);
}

shaozg168 2010-07-09
  • 打赏
  • 举报
回复
int GetLBText(
int nIndex, //索引值从0开始
LPTSTR lpszText
) const;

用一个循环就搞定了。
djjlove_2008 2010-07-09
  • 打赏
  • 举报
回复
建议:〈深入浅出MFC〉这个东西,没有这个函数吧,应该还是要用得到循环。
huhacn 2010-07-09
  • 打赏
  • 举报
回复
LZ想实现什么功能,不太明白,说清楚点啊
//设置combo内容并设定当前显示
SendMessage(GetDlgItem(hWnd, IDC_COMBO_CERT), CB_ADDSTRING, i,(LPARAM)wcaSubIser);
SendMessage(GetDlgItem(hWnd, IDC_COMBO_CERT), CB_SETCURSEL, i, 0);
//获取当前显示
nSel = SendMessage(GetDlgItem(hDlg, IDC_COMBO

33,319

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧