Solved

How to find the selected entry

Posted on 2000-03-01
3
210 Views
Last Modified: 2013-11-20
I have a List Ctrl in report mode. I want to find out the index of the selected entry. How?
0
Comment
Question by:rupak_khurana
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
captainkirk earned 50 total points
ID: 2573343
try this:


POSITION pos = m_ListCtrl.GetFirstSelectedItemPosition();
int nItem = m_ListCtrl.GetNextSelectedItem(pos);
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 2573358
Hi rupak_khurana,

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.GetFirstSelectedItemPosition(); pos != NULL; )
{
 nItem = m_List.GetNextSelectedItem(pos);
 // 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.GetFirstSelectedItemPosition();
if ( pos == NULL )
{
 // no item selected
 return;
}
nItem = m_List.GetNextSelectedItem(pos);
// do something with the item at index nItem
....

hope that helps,

ZOPPO
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 2573361
Hmmm, too late           :(

but you should check the return value from GetFirstSelectedItem() ...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 94
Question regarding Copy/Paste 16 91
WinWaitActive parameters 12 31
if loop in java 3 128
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now