It is important to note that list boxes and combo boxes differ in only two respects:
Unlike the preceding tutorials, I am not going to show the code here because of it length. The code can be found in the ListBoxSample.cpp file in the samples directory. Instead I will refer to code snipits.
Typically you add elements to a list box or combo box like this:
lb->addString( buf );
You acess the selected string using like this:
lb->getSelectedString();
You can get all the elements in the listbox like this:
char buf[MAX_ELEMENTS]; buf[0] = 0; for ( int i = 0; i < lb->getNumberOfItems(); i++ ) { strcat( buf, lb->getString( i ) ); strcat( buf, "\n" ); }
If your lisbox is not a pointer you can access its elements using array notation, for example:
char buf[MAX_ELEMENTS]; buf[0] = 0; for ( int i = 0; i < lb->getNumberOfItems(); i++ ) { strcat( buf, lb[i] ); strcat( buf, "\n" ); }