Link to home
Start Free TrialLog in
Avatar of shark351
shark351Flag for United States of America

asked on

CListCtrl Item Selection??

The "List Box" in MFC has a member function that returns the index of the item selected. GetCurSel().

Can anyone tell me how to do the same thing with a List View Control(CListCtrl)
ASKER CERTIFIED SOLUTION
Avatar of chensu
chensu
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Vinayak Kumbar
Vinayak Kumbar

Hi,

Do the following thing to get the selected item
here m_ctrlPacketSignalListView is the control variable for that list control.

int l_iItemCount = m_ctrlPacketSignalListView.GetItemCount();
            
for(int l_iIndex = 0;l_iIndex<l_iItemCount;l_iIndex++)
{
if(m_ctrlPacketSignalListView.GetItemState(l_iIndex,LVIS_SELECTED))
{
//the l_iIndex gives u the selected item index
break;//u can break or continue
}
                  
}

Try it out.
VinExpert
Avatar of shark351

ASKER

Chensu,
I am using VC++ 5.0
Are the functions you mentioned not available for this version??
I tried to implement them and find documentation but failed on both.
I am not sure. I don't have version 5.0 to check. You may search all the source files of MFC for the function names.
Chensu,

Must not be available for version 5.0.
I will issue you the points since your answer is technically correct. In the meantime I'm using HitTest() to find which item I've selected.
Thanks