Quantcast
Channel: Active questions tagged listview - Stack Overflow
Viewing all articles
Browse latest Browse all 790

Create items in a listview dynamically at runtime with delphi firemonkey

$
0
0

With the code below I can create a button inside a listview item but when I click on the button it causes an error, any ideas to solve it, apparently it could be because I am not able to add a relative to the button.

procedure TForm1.btAddClick(Sender: TObject);var  item : TListItemText;  AItem:  TListViewItem;begin  AItem := ListView1.Items.AddItem;end;procedure TForm1.ListView1UpdateObjects(const Sender: TObject; const AItem: TListViewItem);begin  if AItem.Objects.FindObject('MyButtonCustom') = nil then  begin    Create_BT(AItem);  end;end;procedure TForm1.Create_BT(const AItem: TListViewItem);var  LItem: TListItemTextButton;begin  LItem                       := TListItemTextButton.Create(nil);  AItem.BeginUpdate;  LItem.Name                  := 'MyButtonCustom';  LItem.Text                  := 'MyButtonCustom';  LItem.Height                := 20;  LItem.Width                 := 200;  LItem.PlaceOffset.X         := 0;  LItem.PlaceOffset.X         := 0;  LItem.Align                 := TListItemAlign.Center;  LItem.VertAlign             := TListItemAlign.Center;  LItem.TextAlign             := TTextAlign.Center;  LItem.TextVertAlign         := TTextAlign.Center;  AItem.EndUpdate;  AItem.Objects.Add(LItem);end;```

Viewing all articles
Browse latest Browse all 790

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>