Tech Tip: Tip to Maintain associating Array Orders with Listbox
PRODUCT: 4D | VERSION: 15.x | PLATFORM: Mac & Win
Published On: December 2, 2016
When moving rows in a listbox, all of the column's arrays will also be reordered based on the listbox. A simple trick to take advantage of this is to include invisible columns with associated arrays to maintain the order of all of the arrays based on changes made by the user.
For example with an array of field names and an array of field numbers, the field names are displayed in a listbox, but if row is moved the field numbers should also be rearranged. By assigning the field numbers to an invisible column this action will be performed automatically.
Sample Code:
ARRAY TEXT(tblName_at;0) ARRAY LONGINT(tblNum_al;0) GET FIELD TITLES([Table_1];tblName_at;tblNum_al) |
Sample ListBox:
Running the form and debugging to show the current state of the arrays:
After Moving some rows around and checking the arrays again, both arrays are reordered in the same manner as the listbox: