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 7407859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:48:12+00:00 2026-05-29T05:48:12+00:00

I am creating a control similar to object inspector , So i want to

  • 0

I am creating a control similar to object inspector , So i want to assign any changes to the property to the relevant object.

var

v:TValue ;
 ctx : TRttiContext;
begin

  //  k.IsOrdinal := true ;
v := v.FromVariant(2)  ;


ctx.GetType(tButton).GetProperty('Style').SetValue(Button1, v.AsOrdinal);

end;

above is my code , but i am getting invalid type cast error.

Is it possible to handle any variable and enums .(No need of objects and records as it is very complicated )

  • 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-05-29T05:48:13+00:00Added an answer on May 29, 2026 at 5:48 am

    The call to SetValue needs to read like this:

    SetValue(Button1, TValue.From(TButton.TButtonStyle(2)))
    

    In your code, the use of AsOrdinal is incorrect. That is a function that returns a TRttiOrdinalType. But TRttiOrdinalType is described thus:

    TRttiOrdinalType is the class used to describe all the Delphi ordinal value types, such as Integer, Byte, Word, and so on.

    But you need to provide a TValue that represents a TButtonStyle, which is what the code above achieves.


    As an aside, I initially tried to use the generic TValue.From<T>() function like this:

    SetValue(Button1, TValue.From<TButton.TButtonStyle>(TButton.TButtonStyle(2)));
    

    But that just resulted in the following internal compiler error:

    [DCC Fatal Error] Unit58.pas(38): F2084 Internal Error: URW1147

    QC#103129

    Every time I attempt to use generics I end up being defeated by these internal errors!

    Thanks to Serg for pointing out the alternative form of calling the parameterised method using type inference does not fall foul of the internal error.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating interactive slideshow control in wpf/c#. I've want to create something similar to
I am creating a custom control. I want the template for this control to
I'm creating an error list control similar to the in Visual Studio. Each error
I am creating a rectangle as a custom control object that is placed within
I am creating a custom server control with a property that accepts a String
I'm creating a control and need to pass it the current logon user as
I am creating a Control Template for the Button control in Silverlight 2. I
I am creating a Control Library project. I have some Cursor files which i
How can I go about creating a control that has items in item that
I am creating a user control where in i have different HTML text boxes

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.