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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
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; |
Kod z helpa Delphi. Zmiana nazwy w ListItem.Caption := Names[I][0];
Autor: Toster