hi, im using borland c++ builder and I have created a list view which contains 4 colums of data. Im happy with this bit however I would like to make it so the user can select a row from the listview. I have managed to get it so the user can select the caption value in the first coulmn of the row but I cant get it so the user can select the entire row? Could anyone help me out with the problem?

thanks

Hi, sorry but the link doesnt appear to be working?

I have enables row select from the properties of my listview but Im just having problems calling it

Hi, sorry but the link doesnt appear to be working?

So it seems ... now the link is fixed.

I have enables row select from the properties of my listview but Im just having problems calling it

What do you mean by calling it?

PS. In order for the full row select to work, the listview must be in report mode, i.e. ViewStyle==vsReport (maybe you did not know that?)

i guess i used the wrong terminology there. I think LVS_EX_FULLROWSELECT is the same as enabling the rowselect in the properties of the listview. Anyway now whenever i select an item in my list it highlights the whole row. However I have my code below which wen run, puts the caption (first column content) into a list box. This is just while im testing it to get it to work, but ideally i want all the content from the entire row in the listbox.

I thought there maybe some change in syntax from "Item->Caption" to "Item->Row" to copy the entire row contents but unfortunately i should have known it wasnt going to be this simple:(

TItemStates selected = TItemStates() << isSelected;
   TListItem *Item = ListView1->Selected;
   while (Item){

      ListBox1->Items->Add(Item->Caption);

      Item = ListView1->GetNextItem(Item, sdAll, selected);
   }

However I have my code below which wen run, puts the caption (first column content) into a list box. This is just while im testing it to get it to work, but ideally i want all the content from the entire row in the listbox.

I thought there maybe some change in syntax from "Item->Caption" to "Item->Row" to copy the entire row contents but unfortunately i should have known it wasnt going to be this simple:(

TItemStates selected = TItemStates() << isSelected;
   TListItem *Item = ListView1->Selected;
   while (Item){

      ListBox1->Items->Add(Item->Caption);

      Item = ListView1->GetNextItem(Item, sdAll, selected);
   }

Lookup the SubItems property of the TListItem.

Ive been trying to look that up for a while now using the 'help' provided by the borland compiler but i cant seen to find anything that i can make sense of unfortunately

Ive been trying to look that up for a while now using the 'help' provided by the borland compiler but i cant seen to find anything that i can make sense of unfortunately

Here is how you get items of a single (selected) row

TListItem * Item = ListView1->Selected;
if(Item)
{
    AnsiString text = Item->Caption;
    TStrings * subItems = Item->SubItems;

    for(int ii = 0; ii < subItems->Count; ++ii)
    {
        text += ", " + subItems->Strings[ii];
    }
}
Comments
cheers for the help!
This article has been dead for over six months. Start a new discussion instead.