Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

ListView checkboxes!!??

Posted on 2000-03-02
Last Modified: 2010-04-04
Why is it that when I add an item to a TListView with checkboxes, all items become unchecked?

And how can I remedy this? (I am using D4)

I have found a work-around myself, but it's kind of complicated, I am looking for a simple solution.
Question by:nrico
  • 2

Expert Comment

ID: 2576041
Why not just do this:

  CheckState : TStringList;
  iCount : LONGINT;
  CheckState := TStringList.Create;
  FOR iCount := 0 TO (ListBox1.Items.Count - 1)
    IF ListBox1.Checked[iCount]
//Add your new item

  FOR iCount := 0 TO (CheckState.Items.Count - 1)
    ListBox1.Checked[iCount] :=  (CheckState[iCount] = '1');


It's not ideal and I don't know why Delphi is being a pain but it'll fix your problem

The Neil
LVL 13

Expert Comment

ID: 2576155
I don't have that problem. The boxes remain checked. I wonder how you add a new item.
LVL 17

Accepted Solution

inthe earned 75 total points
ID: 2576196
this is a bug with the component see this report from

http://www.borland.com/devsupport/delphi/fixes/delphi4/vcl.html#win 32 controls\tlistview

Area: vcl\win 32 controls\tlistview
Reference Number: 1065 (Published: 10/27/98)

Status: Fixed in Version 4 Update Pack 2
Date Reported: 8/1/98

Severity: Serious

Type: Basic Functionality Failure


The TListView class clears the checked property of
all items when an item is manually added and its
Checked property is set to TRUE


1.  Create a new applicatoin.
2.  Drop a TButton and a TListview on the form.
3.  Add a bunch of items to the Listview in the OI
4.  Set the Listview's Checked property to True
5.  Add this code to the OnClick of the button --

procedure TForm1.Button2Click(Sender: TObject);
  ListItem: TListItem;
  ListItem := Listview1.Items.Add;
  ListItem.Caption := 'Added item';
  ListItem.Checked := True;

6.  Run the application.   Select the checkboxes of
any or all of the items.  Then press the button.

Notice that the checked properties of all of the
items are cleared.

so the answer is too apply update pack 2 which you an also get from borlands devsupport site.

http://www.borland.com/devsupport/delphi/downloads/index.html#Delphi 4
Regards Barry
LVL 17

Expert Comment

ID: 2576207
Hi epsylon i presume you have updates applied? i also do and dont get this error either ..

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
TEMBEDDEDWB how can i change its user agent ? 8 69
CheckListBox usage 3 71
enhance the following code 3 37
How to save the image in the .cds File ClientDataSet? 1 22
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question