现在的位置: 首页 > 综合 > 正文

How to get CListCtrl clicked item information !!

2013年07月01日 ⁄ 综合 ⁄ 共 735字 ⁄ 字号 评论关闭

you can use the follwing functions to find out the row selected or clicked.

POSITION posList=m_MyListControl.GetFirstSelectedItemPosition( );

int nGetNextSelectedItem=m_MyListControl.GetNextSelectedItem( posList) ;

In the above sample code the "m_MyListControl" is the control member variable of the listcontrol ( member variable define through class wizard).The return value of the function "GetNextSelectedItem( posList)" is the row number selected(starts from 0 row ).

 

 

CListCtrl* pListCtrl = (CListCtrl*) GetDlgItem(IDC_YOURLISTCONTROL);
ASSERT(pListCtrl != NULL);

POSITION pos = pList->GetFirstSelectedItemPosition();
if (pos == NULL)
   TRACE0("No items were selected!/n");
else
{
   while (pos)
   {
      int nItem = pList->GetNextSelectedItem(pos);
      TRACE1("Item %d was selected!/n", nItem);
      // you could do your own processing on nItem here
   }
}

抱歉!评论已关闭.