热情软件屋

 

可选多行列表框控件,应该怎样返回所选行的字符串


编号:QA004622
建立日期: 2002年4月21日 最后修改日期:2002年12月8日
所属类别:

薇薇:
    操作系统: Win2000
    编程工具: VC++6.0
    问题: 我在对话框中使用了一个列表框控件,设置为可选多行,应该怎样返回所选行的字符串?
    水平: 中级

回答:

    使用CListBox::GetSelCount获得选中得行数。使用CListBox::GetSelItems获得选中各行得索引。
    例子:
    // The pointer to my list box.
    
extern CListBox* pmyListBox;
    
    
// Get the indexes of all the selected items.
    
int nCount = pmyListBox->GetSelCount();
    
CArray<int,int> aryListBoxSel;
    
    
aryListBoxSel.SetSize(nCount);
    
pmyListBox->GetSelItems(nCount, aryListBoxSel.GetData());
    
    
// Dump the selection array.
    
#ifdef _DEBUG
    
afxDump << aryListBoxSel;
    
#endif
    

    
    MayMay 问:在ListBox中我如何获得当前选择的行的字符串?
    :知道索引后,可以使用CListBox::GetText 获得字符串。

此问题由李海回答。

 
把这个问题推荐给朋友
   
   
您的意见类别
您的名字
您的电子邮件
您的建议(请尽可能详细)
 
 

版权所有 1997-2008 热情软件屋
如果您有任何建议和意见, 请给我发个电子邮件 askpro@china-askpro.com
Web Designed by ZebraStudio