Add Items Interactively to a List Box

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 allow 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)