How to change the background color of a TListview element?

How can I configure my list to display different background colors, for example, in the image below?

Elements with different background colors.

My list refers to a data source (Livebindng). I want to use a color field to set the backgroud color.

I set up my view in this way:

  • 3 Text elements (designation, date and summary)
  • 1 Bitmap Element (Couleur)

Text elements are tied to a data source, but there is no way to bind my bitmap to the color field.

enter image description here

I filled out the ActivesUpdateObjects event list, but this is not enough, since the bitmap does not change when updating the datasource data record!

procedure TfrmMain.lvTachesActivesUpdateObjects(const Sender: TObject; const AItem: TListViewItem); begin SetItemColor(AItem); end; procedure TfrmMain.SetItemColor(const AItem: TListViewItem; const UpdateColor: Boolean = False); var LObject: TListItemImage; VC: TColor; begin LObject := AItem.Objects.FindObjectT<TListItemImage>('Couleur'); VC:= dtmMain.qrTaches.FieldByName('couleur').AsInteger; if LObject.Bitmap = nil then begin LObject.Bitmap := FMX.Graphics.TBitmap.Create(10,240); LObject.Bitmap.Clear(VC); end else if UpdateColor then LObject.Bitmap.Clear(VC); end; 

Is there a better way? I also looked o use style, but it appears (or I did not find) that itemlistview cannot apply style!

Ps: Firemonkey / Windows / Delphi Berlin XE10.1

+8
delphi firemonkey
source share

No one has answered this question yet.

See related questions:

7
Custom TCustomListbox Item Drawing
3
Why does ListView ignore font and brush settings in a custom drawing?
2
FireMonkey TListView: how to color elements at runtime?
2
Change alternating colors in TListView Firemonkey
one
How to create a simple voice recorder panel in Delphi2009 + Vista
0
TSearchBox before TListBoxItem on Android with Delphi XE8
0
TTrackbar works from right to left, not left to right
0
How to change the background color of TListView elements in Delphi 10?
0
Custom Style Firemonkey List Item Does Not Highlight When Clicked on Android and iOS
0
Invalid Delphi XE3 pointer while trying to free FSQL (TStringList)

All Articles