请问如何在CListBox中得到列表筐中指定行的字符串呢?

yacht99 2006-05-28 07:32:47
我想用一个列表筐显示添加一些动态信息,需要选中一些特定行的字符串并读出来,不知道CListBox中是否有像ComboBox里面的GetLBText(int nIndex, LPTSTR lpszText )这样的函数。
...全文
294 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
gudulyn 2006-05-29
  • 打赏
  • 举报
回复
有问题查msdn
yacht99 2006-05-29
  • 打赏
  • 举报
回复
解决,各位见笑了。
youngwolf 2006-05-28
  • 打赏
  • 举报
回复
m_FlightInfo.GetText(m_FlightInfo.GetCurSel(), m_SelFlightInfo);
第二版是引用,不是指针,学好语言先。
yacht99 2006-05-28
  • 打赏
  • 举报
回复
我在MSDN里面却是查到了GetText这个函数
CListBox::GetText
int GetText( int nIndex, LPTSTR lpszBuffer ) const;

void GetText( int nIndex, CString& rString ) const;

结果我用第二种形式就是老出现上面的错误,不知该如何是好啊。
yacht99 2006-05-28
  • 打赏
  • 举报
回复
谢谢两位,但是当我用第二种时,出现了错误
m_FlightInfo.GetText(m_FlightInfo.GetCurSel(), &m_SelFlightInfo);
其中m_SelFlightInfo是CString m_SelFlightInfo;类型;
结果出现错误
error C2664: 'int __thiscall CListBox::GetText(int,char *) const' : cannot convert parameter 2 from 'const class CString *' to 'char *'
请问这该怎么办啊?
youngwolf 2006-05-28
  • 打赏
  • 举报
回复
第一版本配合GetTextLen使用。
youngwolf 2006-05-28
  • 打赏
  • 举报
回复
int GetText(
int nIndex,
LPTSTR lpszBuffer
) const;

void GetText(
int nIndex,
CString& rString
) const;

15,976

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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