rupak_khurana
asked on
How to find the selected entry
I have a List Ctrl in report mode. I want to find out the index of the selected entry. How?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hmmm, too late :(
but you should check the return value from GetFirstSelectedItem() ...
but you should check the return value from GetFirstSelectedItem() ...
Generally you get list control's selected entries with i.e.:
// assuming m_List is your list control object
....
int nItem;
for ( POSITION pos = m_List.GetFirstSelectedIte
{
nItem = m_List.GetNextSelectedItem
// do something with the item at index nItem
}
....
if you're sure there's only one selected item you can do
....
int nItem;
POSITION pos = m_List.GetFirstSelectedIte
if ( pos == NULL )
{
// no item selected
return;
}
nItem = m_List.GetNextSelectedItem
// do something with the item at index nItem
....
hope that helps,
ZOPPO