6 15 8 Working with Items in Lists

Visual LANSA

6.15.8 Working with Items in Lists

When an application is running, all list items have at least two properties: Selected and Focus. These properties can be set to True or False. For example if an item does not have the focus nor is selected, both these properties are set to False.

The item properties are manipulated using the list's CurrentItem or FocusItem properties.

The CurrentItem is the item in a list box, list view, combo box or grid which is currently being worked with in the application. The FocusItem is the item in a list, tree view or grid which has the focus on the desktop.

CurrentItem can be set by the user by moving the focus on the item (ItemGotFocus event), in which case it is the same as FocusItem, or it can be set by the program in a GET_ENTRY or SELECTLIST command.

The value of the current item is used as the key in database I/O commands. Therefore data is typically fetched in the ItemGotFocus event which sets the CurrentItem.

You can use the SELECTLIST command to examine the properties of every item in a list. For example the following code goes through the list making one item at a time the CurrentItem and tests whether its Selected property is set to true: 

SELECTLIST NAMED(#LTVW_1)

     IF '#ltvw_1.CurrentItem.Selected *eq True'
          do something
     ENDIF
ENDSELECT
 

In lists where it is not possible to select more than one entry at a time (tree view, combo box, and list box), the Focus and Selected properties have always the same value. In other words only the item which has focus can be selected. In lists which allow for multiple selection, only one item can have the focus (Focus property set to True), but multiple items can be selected (usually by using the Ctrl and Shift keys).

You can test for the Focus property of items the same way as you test the Selected property:

#ltvw_1.CurrentItem.Focus *eq True 

 

See also

Understanding selection and loss of selection in list views

Understanding focus and loss of focus in list views

Run-time Properties of Tree Items

The Value of a List Item Is the Value of the Source Field

Updating the Selected Item in a List

Updating All Items in a List

Deleting an Item from a List

Dynamically Assigning Icons in a List View

Creating a Desktop Menu Using Large Icons in List View

Sorting List Views 1

Sorting List Views 2

Saving and Restoring a List from a File

Special Lists: Graph

Special Lists: Multi-line Edit Box

Error Handling in a Grid/List

Ý 6. Creating Applications Using Components