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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:36:59+00:00 2026-05-27T09:36:59+00:00

In Delphi 7, I’m using a TCheckListBox. I want it to use a TStringList

  • 0

In Delphi 7, I’m using a TCheckListBox. I want it to use a TStringList rather than a TStrings, so I can set Duplicates to dupIgnore, and Sorted to TRUE.

Can I just do this:

Form1 = class(TObject
    CheckListBox1: TCheckListBox;  // created by the IDE
end;

procedure TForm1.FormCreate
begin
   CheckListBox1.Items.Free;
   CheckListBox1.Items := TStringList.Create;
   CheckListBox1.Items.Sorted := TRUE;
   CheckListBox1.Items.Duplicates := dupIgnore;
end;

Is this safe? Any caveats or suggestions?

EDIT: Removed declaration for MyStringList and added .Items to the last two assignment lines.

EDIT 2: Trying to compile the above, it looks like I’d have to cast the two final lines like this:

        TStringList(CheckListBox1.Items).Sorted := TRUE;
        TStringList(CheckListBox1.Items).Duplicates := dupIgnore;

Although I might be able to get this to run, I’m asking the question because just getting it to run doesn’t mean it will always run or is safe.

  • 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-27T09:37:00+00:00Added an answer on May 27, 2026 at 9:37 am

    You don’t control what class TCheckListBox uses to store its items. Assigning the Items property a value only assigns its items to the internal storage.

    Also, you shouldn’t call Items.Free;. TCheckListBox depends on its internal instance of TListBoxStrings.

    To answer your edits in your question: Don’t hard-cast the Items property to TStringList, either. The typecast is wrong (the instance exposed by Items is not a TStringList) and will only cause problems.

    Edit, to suggest a workaround for what you seem to try to achieve: To keep the checklistbox sorted, you can set its Sorted property to True. To avoid duplicates, you can check the list before adding an item in code.

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

Sidebar

Related Questions

Using Delphi 2010. I am looking for (possibly) a function or procedure which can
In Delphi I want to determine whether a particular OleVariant can be cast to
Delphi 2009 has changed its string type to use 2 bytes to represent a
Delphi 2009 introduced a hierarchical system for project options configuration, where you set base
Delphi strings use single quotes, for example ' a valid string '. How does
Delphi 2010 has a nice set of new file access functions in IOUtils.pas (I
Delphi 6 is pretty old, I know. Unfortunately there are reasons why I can't
The Delphi XE2 skinning option is fantastic, but there are cases where you want
Using Delphi, I need a function to evaluate the current date and see if
In Delphi 2010 and Delphi 2007 I am using Set8087CW on WebBrowserBeforeNavigate / WebBrowserDocumentComplete

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.