Search code examples
delphifiremonkey

Setting the glyph image in a FireMonkey TListView


I have a FireMonkey TListView in a project. It's using a DynamicAppearance, each item features a couple of text entries and a glyph button. What I cannot seem to figure out is how to set the glyph image for that button when I build the list.

For example, when building the list items, I can do this for a text field:

  lviAmount := lvi.Objects.FindObjectT<TListItemText>('Amount');
  lviAmount.Text := FloatToStrF( tx.amount, ffNumber, 7, 2);

But I cannot see how to do the same thing with a TListItemGlyphButton:

  lviDelete := lvi.Objects.FindObjectT<TListItemGlyphButton>('DeleteButton');
  //then??

How can I set/assign the glyph image on a TListItemGlyphButton in a FireMonkey TListView? Any help would be greatly appreciated.


Solution

  • You cannot do that with a TListViewGlyphButton. It's only for Add, Delete or CheckBox button types. If you want to have an image of your own, use TListItemImage, and use the Bitmap property, e.g:

    lviDelete := lvi.Objects.FindObjectT<TListItemImage>('DeleteButton');    
    lviDelete.Bitmap := SomeBitmap; 
    

    You'll also need to use the OnListViewItemClickEx event to determine whether or not it was the image that was clicked