Board index » cppbuilder » ListView checkbox problem

ListView checkbox problem


2003-10-27 04:55:35 AM
cppbuilder86
I have the following code:
TStringList *Results = new TStringList;
TListItem *ListItem;
if(SearchForFile(GauFolder, "*.gau", Results))
{
Label1->Caption = Results->Count;
for(int x = 0; x < Results->Count; x++)
{
ListItem = ListView1->Items->Add();
ListItem->Caption =
Results->Strings[x].SubString(Results->Strings[x].LastDelimiter("\\")+1,40);
ListView1->Items->Item[x]->Checked = TRUE;
}
}
It does a recursive search for files and returns the results in a Stringlist. I
want ALL the results to have their checkbox checked.
Out of 105 items on the list, there are several that are UNchecked! If I keep
rerunning the application, the same ones are unchecked.
Anyone have any idea what's happening?
Thanx!
Vic Baron
--
Vic Baron
I haven't lost my mind, it's backed up on disk somewhere!
 
 

Re:ListView checkbox problem

"Victor G. Baron" < XXXX@XXXXX.COM >wrote in message
Quote
ListView1->Items->Item[x]->Checked = TRUE;
You already have a pointer to the particular item, so you should be using
that instead of going though the Items property, ie:
ListItem->Checked = true;
Quote
Out of 105 items on the list, there are several that are UNchecked! If I
keep
rerunning the application, the same ones are unchecked.
Unless you are clearing the ListView prior to performing the search, then
you are using the wrong index when accessing the ListView's Items property.
You are using indexes into the TStringList, not the TListView. All the more
reason to just use the TListItem pointer that you already have, then you
don't have to index into the Items property at all.
Gambit
 

Re:ListView checkbox problem

On Sun, 26 Oct 2003 13:05:54 -0800, "Remy Lebeau \(TeamB\)"
< XXXX@XXXXX.COM >wrote:
Quote
>:|
>:|You already have a pointer to the particular item, so you should be using
>:|that instead of going though the Items property, ie:
>:|
>:| ListItem->Checked = true;
>:|
Got it!
Thanx,
Vic
--
Vic Baron
I haven't lost my mind, it's backed up on disk somewhere!
 

{smallsort}