Show: Object Pascal C++
Display Preferences

Associating Objects with a String List

From Appmethod Topics
Jump to: navigation, search

Go Up to Manipulating Strings in a List


In addition to the strings stored in its Strings property, a string list can maintain references to objects, which the string list stores in its Objects property. Like Strings, Objects is an array with a zero-based index. The most common use for Objects is to associate bitmaps with strings for owner-draw controls.

Use the AddObject or InsertObject method to add a string and an associated object to the list in a single step. IndexOfObject returns the index of the first string in the list associated with a specified object. Methods like Delete, Clear, and Move operate on both strings and objects; for example, deleting a string removes the corresponding object (if there is one).

To associate an object with an existing string, assign the object to the Objects property at the same index. You cannot add an object without adding a corresponding string.

See Also

Personal tools
In other languages