1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
Creates a new TListColumn instance and adds it to the Items array.
HIDESBASE TListColumn* __fastcall Add(void);
Description
Call Add to add a new list column to the end of the items array. Add returns the new list column. At design time, use the list view controls Columns editor to add columns to the list view.
This example requires only a blank form. All other objects: TListView, TListColumns, TListItems, are created dynamically. You must add #include <comctrls.hpp> to the top of the unit
void __fastcall TForm1::FormCreate(TObject *Sender)
{
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);
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]);
}
} |
Partager