Board index » cppbuilder » How to get the selected item caption in a listview

How to get the selected item caption in a listview

Can someone help me out here?

I have the caption, and subitems.  When i click on a row i want to get the
caption of any row i click on, whether its the first or the last row.

Thanks

 

Re:How to get the selected item caption in a listview


Use the TListView's Selected property:

    TListItem *Item = ListView1->Selected;
    if(Item)
        // do something with Item->Caption

Or, if you're using the OnChange event, one of its parameters contains the
item that was changed (whenever the caption changes, the image changes, or
the selection changes):

    void __fastcall TForm1::ListView1Change(TObject* Sender, TListItem*
Item, TItemChange Change)
    {
        if(Item)
        {
            if((Change == ctState) && Item->Selected)
                // do something with Item->caption
        }
    }

Gambit

Quote
"David Runner" <runne...@teslainc.com> wrote in message

news:3ca7a819_1@dnews...
Quote
> I have the caption, and subitems.  When i click on a row i want to get the
> caption of any row i click on, whether its the first or the last row.

Other Threads