msd 5 Posted 1 hour ago Hello, I have custom managed type for example: TvatIndividual = record DocumentNumber: string; TurnoverDate: TDate; PaymentDate: TDate; DocumentType: string; Year: integer; TurnoverDescription: string; TurnoverAmount: Currency; end; I need to iterate over this record type and access its fields. For example, if I have 7 items, how can I retrieve the field names and their types using a loop in Delphi? Thanks in advance! Share this post Link to post
Kazantsev Alexey 22 Posted 42 minutes ago program Project1; {$APPTYPE CONSOLE} uses System.Rtti; type TvatIndividual = record DocumentNumber: string; TurnoverDate: TDate; PaymentDate: TDate; DocumentType: string; Year: integer; TurnoverDescription: string; TurnoverAmount: Currency; end; begin for var f in TRttiContext.Create.GetType(TypeInfo(TvatIndividual)).GetFields do WriteLn(f.ToString); ReadLn; end. 1 Share this post Link to post
dummzeuch 1468 Posted 22 minutes ago Just in case anybody else is wondering: This works since Delphi 2010 which was the version that first included the unit rtti. Older Delphi versions did not support RTTI for records. Share this post Link to post