Delphi XE8 Firemonkey TListView – How to set a background color programmatically


A TListView is connected with a style. This style contains a TColorObject named background. If you set the TColorObject.Color (red) in the styledesigner the Treeview will show this Color.
If the Color is set programmatically in the ApplyStyleLookup Event of TListView the background Color remains on the Color (red) set in the style!!!!

procedure TTest.TreeViewlistApplyStyleLookup(Sender: TObject);
co: TColorObject;
co := nil;
if Sender is TListView then co := TListView(Sender).FindStyleResource(‘background’) as TColorObject;
if co <> nil then co.Color := TAlphaColors.Black;
//co is not nil
//TColorObject background is found and black is set, but it remains on red

Comments are closed.