TListItemSubItems (C++)
Description
This example requires only a blank form. All the other objects: TListView, TListColumns, TListItems are created dynamically. You must add comctrls to the uses defs file.
Code
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
const char Names[6][2][10] =
{{"Rubble","Barny"},
{"Michael", "Johnson"},
{"Bunny", "Bugs"},
{"Silver", "HiHo"},
{"Simpson", "Bart"},
{"Squirrel", "Rocky"}};
TListColumn *NewColumn;
TListItem *ListItem;
TListView *ListView = new TListView(this); // The owner will clean this up.
ListView->Parent = this;
ListView->Align = alClient;
ListView->ViewStyle = vsReport;
NewColumn = ListView->Columns->Add();
NewColumn->Caption = "Last";
NewColumn = ListView->Columns->Add();
NewColumn->Caption = "First";
for (int i = 0; i < 6; i++)
{
ListItem = ListView->Items->Add();
ListItem->Caption = Names[i][0];
ListItem->SubItems->Add(Names[i][1]);
}
}
Uses
- Vcl.ComCtrls.TCustomListView.Columns ( fr | de | ja )
- Vcl.ComCtrls.TListColumn.Caption ( fr | de | ja )
- Vcl.ComCtrls.TCustomListView.Items ( fr | de | ja )
- Vcl.ComCtrls.TListItem.SubItems ( fr | de | ja )
- Vcl.ComCtrls.TListItems.Add ( fr | de | ja )
- Vcl.ComCtrls.TCustomListView.ViewStyle ( fr | de | ja )
- Vcl.ComCtrls.TCustomListView.Create ( fr | de | ja )