Reputation: 505
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?
Upvotes: 7
Views: 8099
Reputation: 61
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;
Upvotes: 3
Reputation: 550
For some reason, the answer wasn't working for me to change the text color of a TTextObjectAppearance item. What I did, on a bound/design-made (dynamicAppeareance) Listview is the following:
procedure TReportsForm.lvwReportsUpdateObjects(const Sender: TObject;
const AItem: TListViewItem);
var drw: TListItemDrawable;
cpt: string;
begin
drw:=AItem.Objects.FindDrawable('Concept');
if (drw <> nil) then begin
cpt := AItem.Data['Concept'].AsString;
if (cpt = 'BAD') then
(drw as TListItemText).TextColor := TAlphaColorRec.Indianred
else
(drw as TListItemText).TextColor := TAlphaColorRec.Cadetblue
end;
end;
Upvotes: 0
Reputation: 2287
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;
Upvotes: 8