EDIT ITEM

4D - Documentation   Français   English   German   Spanish   4D v11 SQL, Command Theme List   4D v11 SQL, Command Alphabetical List   4D v11 SQL, Constant Theme List   Back   Previous   Next

version 2004


EDIT ITEM ({*; }object{; item})

ParameterTypeDescription
**If set, object is an object name (string)
If omitted, object is a table or variable
objectForm objectObject name (if * set) or
Table or variable (if * omitted)
itemNumberItem number

Description

The EDIT ITEM command allows you to edit the current item or the item number item in the array or the list set in the object parameter.

This means that the selected item can be modified; entering a character entirely replaces the item content.

If you pass the optional * parameter, you indicate that the object parameter is an object name (in this case, pass a string in object). If you do not pass the parameter, you indicate that the object parameter is a table or a variable. In this case, you do not pass a string but a table or a variable reference.

This command applies to the following enterable objects:

Hierarchical lists

List boxes

Subforms (in this case, only an object name — the subform — can be passed in object),

List forms displayed using the MODIFY SELECTION or DISPLAY SELECTION commands.

If the command is used with an enterable object that is not a list, it then acts the same as the GOTO AREA command.

The command does nothing if the list or the array is empty or invisible. Also, if the list or the array is not enterable, the command only selects the specified item without changing to editing mode. Regarding list boxes, if the column does not allow text entry (entry by check boxes or drop-down lists only), the specified element gets the focus.

The optional item parameter allows you to set the position of the item (hierarchical list) or the row number (list box, list forms and subform in "multiple selection" mode) to change to editing mode. If you do not pass this parameter, the command is applied to the current item for object. If there is no current item, the first item of object changes to editing mode.

Notes:

In hierarchical lists, the EDIT ITEM command automatically causes the list to be redrawn. As a result, you should not call the REDRAW LIST command when the EDIT ITEM command is used.

In subforms and list forms, the command changes the first field of a specified row to edit mode, in the order of entry.

Examples

1. This command can be particularly useful when creating a new item in a hierarchical list. When the command is called, the last item added or inserted in the list automatically becomes editable without the user having to do anything.

The following code may be the method of a button that allows you to insert a new item in an existing list. The default text "New_item" is automatically ready to be changed:

   vlUniqueRef:=vlUniqueRef+1
   INSERT IN LIST(hList;*;"New_item";vlUniqueRef)
   EDIT ITEM(*;"MyList")

2. Given two columns in a list box whose variable names are "Array1" and "Array2" respectively. The following example inserts a new item in the two arrays and passes the new item of Array2 into editing mode:

   $vlRowNum:=Size of array(Array1)+1
   INSERT LISTBOX ROW(*;"MyListBox";$vlRowNum)
   Array1{$vlRowNum}:="New value 1"
   Array2{$vlRowNum}:="New value 2"
   EDIT ITEM(Array2;$vlRowNum)

3. The following example allows changing the first field of the last subrecord in the subselection to editing mode:

   LAST SUBRECORD([Children])
   EDIT ITEM(*;"Subform")

See Also

GOTO AREA, INSERT IN LIST, SET LIST ITEM.


4D - Documentation   Français   English   German   Spanish   4D v11 SQL, Command Theme List   4D v11 SQL, Command Alphabetical List   4D v11 SQL, Constant Theme List   Back   Previous   Next