Board index » cppbuilder » blank line getting added to listview items

blank line getting added to listview items

I'm using a listview to show the results of a filesearch (and the version of
the file found)
The list view shows the path/filename on the left and the version number on
the right (in the Data field).
Somehow a blank line is getting added, but I have stepped thru each item
addition to the listview and see no blank data at all.
Any ideas appreciated!  Thanks in advance.

Here is the section of code where I add stuff to the listview. I called my
listview component ResultsList below:

 // Display the file name.
 ListItem = ResultList->Items->Add();

 // if the exact item exists in the list already, don't put it there again.
if( ResultList->FindCaption(0,
directory+filedata.cFileName,false,true,false) == NULL)
{
   ListItem->Caption = directory + filedata.cFileName ;
   ListItem->SubItems->Add(GetVersionInfo(directory+ filedata.cFileName) );

        // a blank is somehow getting added here...I don't know why???
 }

 

Re:blank line getting added to listview items


Quote
Martin Fensome wrote:
> I'm using a listview to show the results of a filesearch (and the version of
> the file found)
> The list view shows the path/filename on the left and the version number on
> the right (in the Data field).
> Somehow a blank line is getting added, but I have stepped thru each item
> addition to the listview and see no blank data at all.
>  // Display the file name.
>  ListItem = ResultList->Items->Add();

The problem is probably here.
You add an item to the list before the if() block where you check if the item should or shouldn't be
added.
You should change it so that you add the item inside the if() block.

Adam.

Re:blank line getting added to listview items


THANKS!...That was it!!!   I can't believe that I didn't spot that!
I was looking at the Caption and Subitems part and just didn't even see that
one...

Martin

Quote
Adam Savir <ga...@hotmail.com> wrote in message
> Martin Fensome wrote:
> >  // Display the file name.
> >  ListItem = ResultList->Items->Add();

> You add an item to the list before the if() block where you check if the
item
> should or shouldn't be added. You should change it so that you add the
item
> inside the if() block.
> Adam.

Other Threads