[Lazarus] How to populate a TListView programatically

Werner Pamler werner.pamler at freenet.de
Thu Nov 17 00:29:20 CET 2022


Am 17.11.2022 um 00:03 schrieb Aruna Hewapathirane via lazarus:
> Does anyone have any example code that populates a Listview component 
> through code please?
procedure TForm1.FormCreate(Sender: TObject);
var
   item: TListItem;
   i: Integer;
begin
   for i := 0 to 9 do
   begin
     item := ListView1.Items.Add;
     item.Caption := 'Item ' + IntToStr(i);
     item.SubItems.Add('Subitem ' + IntToStr(i) + '/1');
     item.SubItems.Add('Subitem ' + IntToStr(i) + '/2');
     item.ImageIndex := i;
     item.SubItemImages[0] := i+1;
     item.SubItemImages[1] := i+2;
   end;
end;


More information about the lazarus mailing list