RAD Studio VCL Reference
|
Describes the properties of the columns in the list view.
property Columns: TListColumns;
__property TListColumns Columns;
Use Columns to add or delete columns in the list view, or to edit their display properties. When setting Columns at design time a ListView Columns Editor dialog appears. This dialog allows columns to be added or deleted, and the display properties of individual columns to be changed. At runtime, use the Caption, Alignment, and Width properties of the TListColumn objects accessed by the Columns property to change the appearance of the column headers.
C++ Examples:
/* This example requires only a blank form. All other objects: TListView, TListColumns, TListItems, are created dynamically. You must add comctrls to the uses defs file. */ 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]); } }
Delphi Examples:
{ This example requires only a blank form. All other objects: TListView, TListColumns, TListItems, are created dynamically. You must add comctrls to the uses clause of the unit file. } procedure TForm1.FormCreate(Sender: TObject); const Names: array[0..5, 0..1] of string = ( ('Rubble', 'Barney'), ('Michael', 'Johnson'), ('Bunny', 'Bugs'), ('Silver', 'HiHo'), ('Simpson', 'Bart'), ('Squirrel', 'Rocky') ); var I: Integer; NewColumn: TListColumn; ListItem: TListItem; ListView: TListView; begin ListView := TListView.Create(Self); with ListView do begin Parent := Self; Align := alClient; ViewStyle := vsReport; NewColumn := Columns.Add; NewColumn.Caption := 'Last'; NewColumn := Columns.Add; NewColumn.Caption := 'First'; for I := Low(Names) to High(Names) do begin ListItem := Items.Add; ListItem.Caption := Names[I][0]; ListItem.SubItems.Add(Names[I][1]); end; end; end;
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|