From Xojo Documentation

Revision as of 16:28, 12 November 2019 by PLefebvre (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Read-Only Property (As Integer )
IntegerValue = aListBox.LastAddedRowIndex

New in 2019r2

Supported for all project types and targets.

The number of the last row added with the AddRow, AddExpandableRow, or AddRowAt method. LastAddedRowIndex is zero-based. If no rows have been added, LastAddedRowIndex will be the ListBox.None constant (-1). Use this to get the row number when getting or setting values in a multi-column ListBox. See the section on Multi-column listboxes in the Notes section.


This example project consists of a two-column ListBox and two TextFields for the entry of first and last names. A PushButton creates a new row in the ListBox and adds the contents of the TextFields to the ListBox.

PeopleList.CellValueAt(PeopleList.LastAddedRowIndex, 0) = FirstNameField.Value
PeopleList.CellValueAt(PeopleList.LastAddedRowIndex, 1) = LastNameField.Value
PeopleList.SelectedIndex = PeopleList.LastAddedRowIndex // select the newly added row

This code asks the user to add a row if they have not yet done so:

If ListBox1.LastAddedRowIndex = ListBox.None then
MessageBox("Please add a row to continue.")
End If