In Delphi 2010 is there a way to iterate through any kind of indexed property (like Pages of TPageControl, for example)?
Iterate through indexed property in Delphi 2010
786 views Asked by Rafael Piccolo At
2
There are 2 answers
0
On
If I understand you correctly, you want to iterate through these properties via RTTI without knowing anything about the property and its index-values. Because valid index-values must not be a sequence of integer-values this can't be possible. There might be properties with string-indexes or with object-references as index-value. And there is no mechanism in RTTI to query valid index-values wich could be used for an iteration.
No, this is not possible, as there is not standard pattern that:
That's why certain classes have enumerators: it is the pattern that tells the for ... in statement how to enumerate it.
What you can do however is a best estimate:
Finally, it is possible to "retrofit" TPageControl with a GetEnumertor using class helpers (or record helpers if the underlying type is a record).