Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using listboxes... some basic questions

Status
Not open for further replies.

PlasmaZero

Programmer
Dec 6, 2002
13
US
Hi there, I'm new to VC++ and I want to know how to use listboxes. I'm using MVC++ 6.0 and the classwizard gives me two choices for member variables: a string and a control. Could someone please tell me how I use the control to add lines of text to the listbox?
Thanks,
PlasmaZero
 
Yep, list boxes are real easy to use:

1. Add a list box control to your dialog.
2. Use class wizard to add a 'member variable' for the list box control.
3. Choose 'Control' from the menu for this item (not String).
4. Give the member a name such as "m_MyListBox".
5. In your dialog's code, you can add items as follows:

// Let's add an item to our list box
m_MyListBox.AddString("Hello World");

6. You can always remove the item from the list if you know it's zero-based index:

// Assuming our "Hello World" list item is index number [0]
m_MyListBox.DeleteString(0);

There are lots of other interesting things you can do when working with list boxes. To see a full list of the member variables, under VC++ menus, choose 'Help->Search' and do a 'titles-only' search for "CListBox Class Members". This will give you the full list of methods associated with this class and show you the kind of things you can do with it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top