?
Solved

How to find the selected entry

Posted on 2000-03-01
3
Medium Priority
?
249 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
captainkirk earned 200 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month14 days, 7 hours left to enroll

771 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