Shiny Language Reference
Language Reference > User Interface > List Boxes
addlistboxitem
int addlistboxitem(int ID, string Item [, dword Extra]);
Synonyms:
int addlistitem(int ID, string Item [, dword Extra]);
int addlbitem(int ID, string Item [, dword Extra]);
Adds a new string (item) to a list box
The ADDLISTBOXITEM statement adds the specified item text to the list box. It optionally associates a Shiny type dword with the new item. You can use this dword to store item-specific data. For example, if a list box is populated with the contents of an array, the extra data can be used to store the element number of each list box item in its original array. Then, when an item is clicked, the extra data can be read using getlistboxitemextra to immediately retrieve the original array index. This is much faster than iterating through an array to find a matching element. It also ensures uniqueness.
Parameters
ID
The control ID of the control you wish to add the text to
Item
The item string to add
Extra
Optional. A dword of extra data to associate with this listbox item. This may be any value you choose.
Return Value
The zero-based index of the item in the listbox. For example, if this is the third item added to the list box this statement will return integer value 2.
Example Code
// Create the edit box X: 10, Y:10 and sized 200*120
int iListBoxID = createlistbox(1, 10, 10, 200, 120);
// Add "Test item" to the listbox
addlistboxitem(iListBoxID, "Test item");// Add another "Test item" to the listbox but associate 0x12345678 with
// it. This allows us to distinguish between the 2 items with identical
// text
addlistboxitem(iListBoxID, "Test item", 0x12345678);