Add Items to the Collection

Visual LANSA

Add Items to the Collection

The code to Save the employee's full name into the keyed collection is contained in the Click event of the Save button:

 

Change Field(#LISTCOUNT) To('#Employee.ItemCount + 1')

Set Com(#Employee<#ListCount>) Value(#FullName.Value) 

In the above note that:

  • The keyed collection property ItemCount (the number of items in the collection) is used to compute the next available key
  • When you work with an item in a collection, you refer to it with the name of the collection and the key field: #Employee<#ListCount>
  • You create the item in the collection simply by setting its value

Ý Example 1: Create a Keyed Collection