Delphi 7: how to fill a Tlistview

TimeIsNear picture TimeIsNear · Aug 12, 2010 · Viewed 8.5k times · Source

I've a Tlistview with 3 columns, I need from Tcollection object as this follow

FListeDispoProduit := TListeDispoProduit.Create(TProduit);

  with (FListeDispoProduit) do
  begin
    with TProduit(Add) do
    begin
      Name := 'Produit 01';
      CIP := 'A001';
      StockQty := 3;
    end;

But when I try to put this object into the Tlistview only the first column (Name)is populate I write this:

for i := 0 to FListeDispoProduit.Count -1 do
     Tlistview1.Items.Insert(i).Caption := TProduit(FListeDispoProduit.Items[i]).Name;

I need fill those 3 columns (Name,cip,StockQty ), how can I do this?

Thank you.

hope I be clear.

Answer

Im0rtality picture Im0rtality · Aug 12, 2010
for i := 0 to FListeDispoProduit.Count -1 do  
   with ListView1.Items.Add() do begin
      Caption :=  TProduit(FListeDispoProduit.Items[i]).Name;  
      SubItems.Add(TProduit(FListeDispoProduit.Items[i]).CIP);   
      SubItems.Add(IntToStr(TProduit(FListeDispoProduit.Items[i]).StockQty));  
   end; 

And add more columns in TListView