Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Populating a list

I have a very simple question I'm having a hard time finding a solution to. I want to create a list of selections where the user can select one item from the list. If the user selects one item, then selects another item from the same list, the first selection would be unselected. Should I use a list box for this? If yes, how would I populate the list and how would I be able to determine when and item ahs been selected, and which item from the list has been selected?

Thanks in advance.
0 Kudos
Message 1 of 4
(3,243 Views)
Should I use a list box for this?

You could use either CComboBox or CListBox for this.

If yes, how would I populate the list and how would I be able to determine when an item has been selected, and which item from the list has been selected?

You can populate the list via the CListBox::AddString or CListBox::InsertString methods. You can find out when an item has been selected by handling the LBN_SELCHANGE notification. You can easily add a handler for this notification by right-clicking on the listbox, click "Events...", and select LBN_SELCHANGE, and click Add Handler. You can find out which item from the list has been selected via the CListBox::GetCurSel method.

- Elton
0 Kudos
Message 2 of 4
(3,242 Views)
For background information on MFC, you might want to check out Programming Windows with MFC, by Jeff Prosise.

Feel free to keep posting these types of questions to this forum - I just wanted to give you a pointer to some good information about MFC in general.
0 Kudos
Message 3 of 4
(3,243 Views)
Thanks for the reference. You're actually the second person who has recommended this book to me. I've been doing some research and everyone who's read it has wonderful things to say about it. I'm definitely going to check it out. Thanks again.
0 Kudos
Message 4 of 4
(3,243 Views)