..., but how can you create a TItem object in order to search the list using A.IndexOf(T:TItem) otherwise?
You can't, period.
Each item (=object/class) that you create is an individual item, that has no association with all the other items that you have stored in the list (or any other class item that you have created outside that list).
The way to use (a specialized) TObjectList is by creating those individual items, store them and parse the list in order to 'find' an item. In case you'd like to use indexOf you would store the pointer to that particular item into a variable so that you can use that later on.
I think that what you're actually looking for is a so-called associative list, e.g. a list which can store items for you but that are associated with a (unique) number or string.
For simple cases you can use
TStringList for that, as it is also
capable of storing objects. But, since you are already trying to solve things with generics, you would be actually looking for a so called dictionary list. In such a list you can store items and associate each item stored with a string or other value.
But, i believe fpc has no dictionary class of it's own ? You might be able to find something
here or perhaps some-one around here as a link to a generics collection that might be able to help you out.
If a dictionary is not what you seek then the only other option that could perhaps be viable is to adjust the objectlist to your likings , by for example overriding the indexof method or by adding helpers that allow you to search the list as you would like (on field names).
edit:
PS: found a thread
here with a link to
here.