ItemData Property

Visual Studio .NET 2003

Uses an index to reference a one-dimensional array that contains the same number of items as a ComboBox or ListBox control's List property setting. Not available at design time; read/write at run time.

Control.ItemData(nIndex)[ = nData]

Property Values

Specifies the index of the item to store or retrieve. The nIndex corresponds to the display order of the items in the list.
The number to store or retrieve from the ItemData list.


Use the ItemData property to associate a specific number with each item in a combo box or list box. You can then use these numbers in code to identify the items in the list. For example, you can use an identification number to identify each employee name in a list box. When you fill the list box, also fill the corresponding elements in the ItemData array with the employee numbers.

Note   When you insert an item into a list with the AddItem method, an item is automatically allocated in the ItemData array as well. However, the value is not initialized; it retains the value that was in that position before you added the item to the list. When you use the ItemData property, be sure to set each element's value when adding new items to a list.

See Also

AddItem Method | ItemIDToIndex Method | List Property | ListItemID Property | NewItemID Property | RemoveItem Method | Selected Property | TopItemID Property

Applies To: ComboBox | ListBox