KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Changing Listbox Insert Row Position
PRODUCT: 4D | VERSION: 17 | PLATFORM: Mac & Win
Published On: August 2, 2019

When using the command, LISTBOX INSERT ROWS, the default position of the newly added row is above the selected row. This inserted row position can be manipulated.

Use this code to manipulate the position of the added row:

LISTBOX GET CELL POSITION(*;"List Box";$column;$row)
LISTBOX INSERT ROWS(*;"List Box";$row+1;1)
LISTBOX SELECT ROW(*;"List Box";$row+1)


In the first line of code, the position of the column and row are grabbed from the list box. In the second line, a new row is inserted relative to the position of the selected row. In this example, the position of the new row is set to be at $row+1. This inserts the new row below the selected row. The last line of code changes the highlight selection to the newly inserted row, therefore it is set to the same position as the inserted row ($row+1).

In both of the images below, the record "a" was selected before pressing the "Add Row" button. It shows the different positions of the new inserted row. The default position is using $row and the manipulated is position is using $row+1.


(Default – New row inserted above record “a”)


(Manipulated – New row insets below record “a”)