List - CurrentItem Property

The last item in the list touched either in the UI or via a list related command

Member of List (PRIM_MD.List)

Data Type - PRIM_MD.ListItem - List Item


CurrentItem is the item in the list that was last touched either by the mouse, keyboard or a LANSA list command such as SELECTLIST or GET_ENTRY.
When CurrentItem is set, the field values associated with the list definition will be returned to the component. This ensures that the field values for the last item are correct when the event is fired.
Care is required when relying on CurrentItem to identify the item last clicked. This will actually be the FocusItem and it won't change until another item is clicked.  CurrentItem however can be affected by a simple MouseOver.
Currentitem is best suited to processing directly related the list e.g. DoubleClick events or SELECTLIST.
When dealing with actions driven by external sources, for example a button click to process the last item, using FocusItem is recommended.
Using the FOR command to iterate over the items in a list will not affect CurrentItem.


Using CurrentItem to set the related reference for the last item added to a list.
Add_Entry To_List(#List)
#List.CurrentItem.RelatedReference <= #CurrentEmployee
Using CurrentItem in a SELECTLIST loop to check item state. Here the selected items in the list are being totalled.
SelectList Named(#List)
    Continue (*Not #Item.Selected)
   #TotalSalary += #Salary
Using the FOR command iterates over the items in their sorted sequence, but CurrentItem will not be set.
Use GET_ENTRY to set the CurrentItem to ensure field values are returned to the component.
For Each(#Item) in(#List.Items)
   Get_Entry Number(#Item.Entry) From_List(#List)
   * User processing here

See also

All Component Classes

Technical Reference

LANSA Version 15, April 2020