SET LIST ITEM

4D - Documentation   Français   English   German   4th Dimension 2003, Command Theme List   4th Dimension 2003, Command Alphabetical List   4th Dimension 2003, Constant Theme List   Back   Previous   Next

version 6.0


SET LIST ITEM (list; itemRef; newItemText; newItemRef{; sublist{; expanded}})

ParameterTypeDescription
listListRefList reference number
itemRefNumberItem reference number
or 0 for last appended to the list
newItemTextStringNew item text
newItemRefNumberNew item reference number
sublistListRefNew sublist attached to item, or
0 for no sublist (detaching current one, if any), or
-1 for no change
expandedBooleanIndicates if the optional sublist will be expanded or
collapsed

Description

The SET LIST ITEM command modifies the item whose item reference number is passed in itemRef within the list whose reference number is passed in list.

If there is no item with the item reference number you passed, the command does nothing. You can optionally pass 0 in itemRef to modify the last item added to the list using APPEND TO LIST.

If you work with item reference numbers, build a list in which the items have unique reference numbers, otherwise you will not be able to distinguish the items. For more information, see the description of the command APPEND TO LIST.

You pass the new text for the item in newItemText. To change the item reference number, pass the new value in newItemRef; otherwise, pass the same value as itemRef.

To attach a list to the item, pass the list reference number in subList. In this case, you also specify if the newly sublist is expanded by passing TRUE in expanded; otherwise, pass FALSE.

To detach a sublist already attached to the item, pass 0 (zero) in sublist. In this case, it is a good idea to have previously obtained the reference number of that list using GET LIST ITEM, so you can later delete the sublist using CLEAR LIST, if you no longer need it.

If you do not want to change the sublist property of the item, pass -1 in sublist.

Note: Even if they are optional, both the sublist and expanded parameters must be passed jointly.

Example

1. hList is a list whose items have unique reference numbers. The following object method for a button adds a child item to the current selected list item.

   $vlItemPos:=Selected list item(hList)
   If ($vlItemPos>0)
      GET LIST ITEM(hList;$vlItemPos;$vlItemRef;$vsItemText;$hSublist;$vbExpanded)
      $vbNewSubList:=Not(Is a list($hSublist))
      If ($vbNewSubList)
         $hSublist:=New list
      End if 
      vlUniqueRef:=vlUniqueRef+1
      APPEND TO LIST($hSubList;"New Item";vlUniqueRef)
      If ($vbNewSubList)
         SET LIST ITEM(hList;$vlItemRef;$vsItemText;$vlItemRef;$hSublist;True)
      End if 
      SELECT LIST ITEM BY REFERENCE(hList;vlUniqueRef)
      REDRAW LIST(hList)
   End if 

2. See example for the command GET LIST ITEM.

3. See example for the command APPEND TO LIST.

See Also

GET LIST ITEM, GET LIST ITEM PROPERTIES, SET LIST ITEM PROPERTIES.


4D - Documentation   Français   English   German   4th Dimension 2003, Command Theme List   4th Dimension 2003, Command Alphabetical List   4th Dimension 2003, Constant Theme List   Back   Previous   Next