双击CListBox中的选项,怎么获取选中项的信息
1个回答
展开全部
获取当前选择行:
// The pointer to my list box.
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 $amp;>amp;$nbsp;1))
{
if (++nIndex $amp; pmyListBox->SetCurSel(nIndex);
else
pmyListBox->SetCurSel(0);
}
获取某行text:
// The pointer to my list box.
extern CListBox* pmyListBox;
// Dump all of the items in the list box.
#ifdef _DEBUG
CString str, str2;
int n;
for (int i=0;i $amp; {
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 $amp; }
// The pointer to my list box.
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 $amp;>amp;$nbsp;1))
{
if (++nIndex $amp; pmyListBox->SetCurSel(nIndex);
else
pmyListBox->SetCurSel(0);
}
获取某行text:
// The pointer to my list box.
extern CListBox* pmyListBox;
// Dump all of the items in the list box.
#ifdef _DEBUG
CString str, str2;
int n;
for (int i=0;i $amp; {
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 $amp; }
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询