Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add items to TListView with DynamicAppearance?

How can I add items to DynamicAppearance Listview in runtime? On design mode I created the layout of ListView which I want. I added 3 TTextObjectAppearance. How can I set those 3 TTextObjectAppearance text dynamically?

like image 310
shariful Avatar asked May 20 '16 21:05

shariful


2 Answers

I took the time to format the answer that was posted in the original question's comments by the original poster.

var list : TListViewItem; 
    ldes, lOrder, lLegal : TListItemText; 
begin 
   list := ListView1.Items.Add; 
   ldes := list.Objects.FindObjectT<TListItemText>('Description'); 
   lOrder := list.Objects.FindObjectT<TListItemText>('OrderId'); 
   lLegal := list.Objects.FindObjectT<TListItemText>('LegalCode'); 
   ldes.Text := 'Mouri'; 
   lOrder.Text := 'Love'; 
   lLegal.Text := 'You' 
end; 
like image 85
Freddie Bell Avatar answered Nov 01 '22 15:11

Freddie Bell


Another way to change the text would be:

for i := 0 to Listview1.Itemcount-1 do begin

  Listview1.Items.AppearanceItem[i].Data['Description'] := 'Mouri';
  Listview1.Items.AppearanceItem[i].Data['OrderID'] := 'loves';
  Listview1.Items.AppearanceItem[i].Data['LegalCode'] := 'YOU!';

end;
like image 39
DAVID SMITH Avatar answered Nov 01 '22 13:11

DAVID SMITH