NewIndex, NewItemId

These properties tell you the index and itemid of the item you most recently added to a list or combo box.

Usage

nIndexAssigned = oObject.NewIndex
nItemIdAssigned = oObject.NewItemId
To understand the distinction between index and itemid, see the entries for AddItem and for ListIndex and ListItemId. These two have the same division of labor as those last two properties.You're far more likely to need NewItemId than NewIndex. If you're adding a series of items to a multi-column list, NewItemId can be a big help. As long as you use it every time, you don't have to worry about finding unique itemids.

Example

* Use NewItemId to avoid counting as you add a series of items
* to a multi-column list.
* This is the same example as in the AddListItem entry, 
* except that NewItemId is used instead of an explicit counter
 
* Fill a list box with the names and titles from Employee
* This code might be in the Init method of the list box
This.ColumnCount = 3
This.ColumnWidths = "75,60,150"
 
SELECT Employee
SCAN
   This.AddListItem(Last_Name)
   This.AddListItem(First_Name, This.NewItemId, 2)
   This.AddListItem(Title, This.NewItemId, 3)
ENDSCAN
 
* To see them in alpha order, add
This.Sorted=.T.

See Also

AddItem, AddListItem, ComboBox, ListBox, ListCount, ListIndex, ListItemId


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .