Board index » cppbuilder » ListView->Subitems

ListView->Subitems

Can someone give me a simple example of filling a ListView row (viewstyle
vsReport) that has mutiple columns?
The help refers to using 'subitem', but the example only fills one
additional column:
EX from Help...

     ListItem->SubItems->Add(Names[i][1]);// A 2 col char array, but here
refering to only one array entry..

I would like to add to the all columns I have in the ListView for each
row...

Col1    Col2    Col3    .....    Col(n)
-----    -----    -----    .....    ------
A        B        C           ....    data...

I used the following so far for Col1 and Col2, but what about the rest?

    ListItem = ((TListView*)lParam)->Items->Add();
    ListItem->Caption = str; //str is an AnsiString
    ListItem->SubItems->Add("sometext");//I put a constant here, but how do
I add to the other cols?

Thanks in Advance.

 

Re:ListView->Subitems


Each column item is just another item in the SubItems collection.  So to
fill your other colums, just add more strings:

    ListItem->SubItems->Add("Text for column 1");
    ListItem->SubItems->Add("Text for column 2");
    ListItem->SubItems->Add("Text for column 3");
    ListItem->SubItems->Add("Text for column 4");

Gambit

Quote
"JDP" <christoph...@ruthschris.com> wrote in message

news:3b71734c_2@dnews...
Quote
> Can someone give me a simple example of filling a ListView row (viewstyle
> vsReport) that has mutiple columns?
> The help refers to using 'subitem', but the example only fills one
> additional column:

Other Threads