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

  • Home
  • SEARCH
  • 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 619427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:39:15+00:00 2026-05-13T18:39:15+00:00

In Delphi I have an own class which is based on TList. It is

  • 0

In Delphi I have an own class which is based on TList. It is TPetList. Every instance of TPetList can have some items of the class TPet. The instance of TPetList is displayed in a TListView component using a for loop.

TPet is based on TObject and has the following fields:

  • city
  • age
  • breed

Now I have a list of checkboxes where the user can tick the breeds he wants to see. So if he only wants to see pets of breed XYZ I want to show only entries which have the value of “breed” set to “XYZ” while the order in TPetList and TListView must remain the same.

How can I do this?

If I delete the items in TPetList and show the rest in TListView, everything’s fine until the user wants to see another breed. This breed has been deleted before and can’t be showed.

  • 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-13T18:39:16+00:00Added an answer on May 13, 2026 at 6:39 pm

    Instead of deleting, try selecting out a new list. Something like this:

    function TPetList.Filter(criteria: TPetCriteria): TPetList;
    var
      i: integer;
    begin
      result := TPetList.Create;
      for i := 0 to self.Count - 1 do
        if criteria.matches(self[i]) then
          result.add(self[i]);
    end;
    

    How you implement the criteria is up to you, but that’s the general idea. Remember that the list this returns is a sub-view and does not own the items it contains, so don’t free them when you free the filtered list.

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

Sidebar

Related Questions

Is it possible in Delphi to have a class method invoke an inherited instance
I have an old Delphi codebase I have to maintain, lots of DLLs, some
I have a delphi (Win32) web application that can run either as a CGI
I just got Delphi 2009 and have previously read some articles about modifications that
I have a Delphi 7 application that has two views of a document (e.g.
I have a Delphi DLL with a function defined as: function SubmitJobStringList(joblist: tStringList; var
I have a Delphi Web Server setup and running, publishing Web Services, and I
I have a Delphi 5 executable that calls into a .NET assembly via the
I have a Delphi application similar to Taskbar Shuffle that includes a hook dll.
I have installed Delphi Prism and XNA Game Studio 3.0. I have managed to

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.