?
Solved

Choosing names from  list box in Visual C++

Posted on 2000-04-18
2
Medium Priority
?
171 Views
Last Modified: 2010-04-02
I have a problem with list box in visual c++. After å name search I show the results in a list box, but I don't know how I can pick out the right name?
I use xxx.GetText() but then I only get the name displayed in the list box.. I want to get the data that is linked to the name displayed in the list box. (The data linked to each name is adress, phone nr and so on...)
Is there a command that returns the line nr in the list box? Or returns a path to the data linked to the name I clicked on?
0
Comment
Question by:andreas75
[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 Comments
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 2726110
How was the data loaded into the listbox. Was the data associted with each entry using SetItemData or SetItemDataPtr if so then you can use GetItemData or GetItemDataPtr.

If you have the name can you walk the list of results (the ones you used to load the listbox) and find a match and then get the name, number etc

Sorry I can't be more exact without more info :)
0
 
LVL 1

Accepted Solution

by:
tvanceplus earned 300 total points
ID: 2727105
Here is some code where the resource ID for your list box is IDC_LIST.

int nr;

nr=getitemtoget();

....

CListBox* pList;
pList=(CListBox*)GetDlgItem(IDC_LIST);

CString text;

pList->GetLBText(nr,text);

Now text is whatever text was on line nr or the list box. This also works for combo boxes.

Good Luck!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
Suggested Courses

777 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