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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:23:54+00:00 2026-05-22T03:23:54+00:00

I have a class of type TObject called CModelItem I want to have a

  • 0

I have a class of type TObject called CModelItem

I want to have a list of these objects and be able to modify the values of each one

So, I created a class

CQueueList = class(TList)

private

public

end;

and I make

QueueList : CQueueList;

in var

Now, I can add the CModelItem to this list, like so:

QueueList := CQueueList.Create;
for idx := 0 to ndx - 1 do
  begin
    MyItem := CModelItem.Create;
    MyItem.CopyHead(CModelItem(RunList.Objects[idx]));
    MyItem.ReadData;
    MyItem.NumOfIterations := NumRepEdit.Value;
    MyItem.IsInQueue := True;
    MyItem.LogEvents := EventsCheckBox.Checked;
    MyItem.LogMatch := MatchCheckBox.Checked;
    MyItem.LogUpdates := UpdatesCheckBox.Checked; 

    QueueList.Add(MyItem);
  end;

I can also use it, so I can do:

DefForm := TRunDefForm.Create(Self, QueueList.Items[idx]);

with DefForm taking in a component and a CModelItem

But I’m running into problems trying to modify the values of an object in QueueL

First, I can’t access something like MyItem.IsInQueue by doing

QueueList.Items[idx].IsInQueue := blah;

because it tells me IsInQueue is ‘an undeclared identifier’

I’ve also tried making a new CModelItem and copying the information over, like this:

idx := QueueListBox.ItemIndex;
MyItem := QueueList.Items[idx];

and this compiles fine, but throws up an ‘access violation error’ when it goes into that function

I noticed that QueueList.Items[idx] is a pointer, but I’m really not sure how I should be accessing it

  • 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-22T03:23:55+00:00Added an answer on May 22, 2026 at 3:23 am

    The compiler complains because TList.Items returns an untyped pointer.

    You can use a typecast:

      CModelItem(QueueL.Items[idx]).IsInQueue := blah;
    

    You can also reimplement the Items property in your CQueueList class:

    private
      function GetItems(Index: Integer): CModelItem;
    public
      property Items[Index: Integer]: CModelItem read GetItems; default;
    end;
    
    function CQueueList.GetItems(Index: Integer): CModelItem;
    begin
      Result := inherited Items[Index];
    end;
    

    As you’ve seen, using a local variable works; although the access violation is a bug probably somewhere else in your code.

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

Sidebar

Related Questions

I have two objects of the same class (Model) type. I want to check
In one file, I have a baseclass with a ID-property: type TBase = class(TObject)
I have class and I want to initalize column that stores pictuer with type
I have a class class PCB { public: struct { string type; **linklist list;**//refer
I have a class called Question that has a property called Type. Based on
I have a class with a Property called 'Value' which is of type Object.
I have the following classes: type TSong = class(TObject) private FArtist: String; FTitle: String;
What I want to do: I have a few objects in a genric list.
I have a unit something like this type TMyClass = Class(TObject) private AnInteger :
I have a Class with generic type: class Foo<T> { protected boolean validateType(Object obj){

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.