Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8741007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:13:55+00:00 2026-06-13T11:13:55+00:00

I got some problems with RTTi .. i wana to enumerate all constans values

  • 0

I got some problems with RTTi .. i wana to enumerate all constans values in Record type

 type TMyRecord = record
  const
    value1: Integer=10;
    value2: Integer=13;
    value3: Integer=18;
    value4: Integer=22;
 end;
procedure TForm3.Button1Click(Sender: TObject);
var
 ctx:TRttiContext ;
 Field:rtti.TRttiField       ;
begin
 for Field in ctx.GetType(TypeInfo(TMyRecord)).GetFields     do
 ListBox1.Items.Add(Field.Name  );  // i got nothing
end;

but when my Record is not a const , my code work fine

 type TMyRecord = record
   value1: Integer;
   value2: Integer;
   value3: Integer;
   value4: Integer;
  end;
procedure TForm3.Button1Click(Sender: TObject);
var
 ctx:TRttiContext ;
 Field:rtti.TRttiField       ;
begin
 for Field in ctx.GetType(TypeInfo(TMyRecord)).GetFields     do
 ListBox1.Items.Add(Field.Name  );  //its work
end;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:13:56+00:00Added an answer on June 13, 2026 at 11:13 am

    RTTI cannot enumerate constants. Whilst they might appear to be fields, they are not. They are implemented just like any other constant, inside the record’s namespace.

    You may have to consider an alternative approach. For example you could use attributes instead of constants. Or perhaps adding a class function that enumerates these constants.

    Yet another approach would be like this:

    type
      TMyRecord = record
        value1: Integer;
        value2: Integer;
        value3: Integer;
        value4: Integer;  
     end;
    
    const
      MyConst: TMyRecord = (
        value1: 10;
        value2: 13;
        value3: 18;
        value4: 22
      );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got some problems. I've got this code: Dim infoID As Integer = objCommand1.ExecuteScalar()
I got some problems with this query i need all my selectors but i
got some problems. Built an applet that has to be used step-by-step. After each
got some problems deploying a java web application on jboss 7.1... Stepped through the
I got some problems here, I can't make my find_by_sql request to render an
I got some problems in Datagrid WPF I have a datagrid, and I want
i got some problems with my history listview. on logcat it stated the cause
I got some problems with EOF and stdio in a communication pipeline between a
I got some problems with the error Link error LNK2005 ... already defined. The
I've got some problems on a .NET site where both Latin (åäö) and Latvian

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.