Solved

Choosing names from  list box in Visual C++

Posted on 2000-04-18
2
167 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
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 100 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SetCurrentDirectory path limit 7 144
C++ question 3 74
Why isn't object file created? 6 86
I could not set window to top 4 40
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

685 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