Tech Tip: List Box keep record in highlight
PRODUCT: 4D | VERSION: 13.2 | PLATFORM: Mac & Win
Published On: January 29, 2013
This tech tip is about modify, save and keep highlighted of a record that shown in a list box. A list box might be implemented which enables the user to choose and modify any records. After a record is modified and saved, you might want to keep that record highlighted, so that it's easier for the user to see the record he/she just modified, as well as verify the changes. Following code provides one of the solutions of how this can be implemented.
C_LONGINT($selected_l) // Save the current selection with current ordering COPY NAMED SELECTION([Table1];"lastselection") // Make sure the selected record is loaded so that // the modification is applied to the record $selected_l:=Selected record number([Table1]) GOTO SELECTED RECORD([Table1];$selected_l) // // Modify record here // SAVE RECORD([Table1]) // Restore the saved selection USE NAMED SELECTION("lastselection") // Must clear once the named selection is restored to avoid memory leak CLEAR NAMED SELECTION("lastselection") // Reselected the row in list box LISTBOX SELECT ROW(*;"MyListBox";$selected_l;Listbox replace selection) |