How to add additional data to the list box?
Article Metadata
Code Example
Article
The list boxes have predefined formats to display data and the datainput is given according to those formats and are displayed. Suppose if we want to add more columns and store user data in the list but they need not be displayed.
We can achieve this by creating an array list and store the all the data entries in the array list. When the array list is passed to the listbox model it reads the data corresponding to its own format and rest of the data would not be displayed (remain invisible). But still the invisible data can be retrieved by accessing the array list since it is stored there.
Exemplification
The CAknSingleGraphicStyleListBox list box has the following format:
- "%d\t%S\t%d\t%d"
where:
- - %d's correspond to the index of icon used in the A, C and D columns
- - %S corresponds to a string that will be displayed in the B column
We create an array list with these four columns and pass it to the listbox model.
If the input data for row1 is ICON1, USERDATA1, ICON2, ICON3 respectively, then the data displayed in the CAknSingleGraphicStyleListBox would be
- ICON1 USERDATA1 ICON2 ICON3.
For the same array list two more columns can be added, for example USERDATA2 and USERDATA3
- "%d\t%S\t%d\t%d\t%S\t%S".
The input data for the list box would now be ICON1, USERDATA1, ICON2, ICON3, USERDATA2,USERDATA3 and the output displayed in the CAknSingleGraphicStyleListBox would still be
- ICON1 USERDATA1 ICON2 ICON3.
But the values of the invisible data USERDATA2 and USERDATA3 can be retrieved since they are being stored in the item array list.
Related Links:
- How to add ScrollBar in ListBox
- How to add Marquee effect in ListBox
- How to create a simple listbox in Symbian C++


(no comments yet)