Add Items Interactively to a List Box Sample
File: ...\Samples\Solution\Controls\Lists\Ladd.scx
This sample demonstrates adding and removing list box items. When a user types text in the text box and presses ENTER, the text in the text box is added to the list and the cursor is returned to the text box so that the user can enter another value.
To make it possible for a user to interactively add items to a list, use the AddItem method. In the sample, the following code in the text box KeyPress event adds the text in the text box to the list box and clears the text box when the user presses ENTER:
PARAMETERS nKeyCode, nShiftCtrlAlt
IF nKeyCode = 13 && Enter Key
THISFORM.lstAdd.AddItem (This.Value)
THIS.Value = ""
ENDIF
The following code in the DblClick event of the list box removes the item that was double-clicked, sending the value to the text box:
THISFORM.txtAddText.Value = This.List(This.ListIndex)
THIS.RemoveItem (This.ListIndex)
See Also
Tasks
Display Multiple Columns in a List Box Sample
Display Pictures in a List Sample
Fill a List with Values from Different Sources Sample
Move Items Between List Boxes Sample
Multiselect Items in a List Box Sample
Open Multiple Files Interactively Sample
Treeview/Listbox Drag and Drop Sample