Solved

Choosing names from  list box in Visual C++

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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

739 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