DesktopListBox.LastAddedRowIndex

From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

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

New in 2021r3

Supported for all project types and targets.

The number of the last row added with the AddRow, AddExpandableRow, or AddRowAt method. If no rows have been added, LastAddedRowIndex will be the DesktopListBox.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.

Example

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

PeopleList.Addrow("")
PeopleList.CellTextAt(PeopleList.LastAddedRowIndex, 0) = FirstNameField.Text
PeopleList.CellTextAt(PeopleList.LastAddedRowIndex, 1) = LastNameField.Text
PeopleList.SelectedIndex = PeopleList.LastAddedRowIndex // select the newly added row
FirstNameField.SetFocus

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

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