<div class="meta" robots="noindex">

</div>

# ListBox.LastIndex

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<div class="warning">

<div class="title">

Warning

</div>

This item was deprecated in version 2019r2. Please use `DesktopListBox.LastAddedRowIndex<desktoplistbox.lastaddedrowindex>` as a replacement.

</div>

## Description

The number of the last row added with the AddRow, AddFolder, or InsertRow method. <span class="title-ref">LastIndex</span> is zero-based. <span class="title-ref">LastIndex</span> defaults to -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.

## Sample code

This example project consists of a two-column `ListBox</api/deprecated/listbox>` and two `` TextField</api/deprecated/textfield>`s for the entry of first and last names. A :doc:`PushButton</api/deprecated/pushbutton> `` creates a new row in the `ListBox</api/deprecated/listbox>` and adds the contents of the `` TextField</api/deprecated/textfield>`s to the :doc:`ListBox</api/deprecated/listbox> ``.

``` xojo
PeopleList.Addrow("")
PeopleList.Cell(PeopleList.LastIndex, 0) = FirstNameField.Text
PeopleList.Cell(PeopleList.LastIndex, 1) = LastNameField.Text
PeopleList.ListIndex = PeopleList.LastIndex ' select the newly added row
FirstNameField.SetFocus
```

## Compatibility

All projects types on all supported operating systems.
