I have got some of the latest version of the VirtualTreeView and try to
change the background color of the whole row of TVirtualStringTree both in selected and in non-selected states (toFullRowSelect is included somewhere). There is a lot of similar questions with different answers but none seems to fit well. In all of them you just write a handler that includes the code snippet like this:
TargetCanvas.Brush.Color := SomeColor;
TargetCanvas.FillRect(SomeRect);
But it's not that simple as I thought:
OnBeforeCellPainthandler works well only if the row is not selectedOnDrawTexthandler works in both states but the entire row looks divided by spaces between cellsOnBeforeItemErasedaffects the whole row but again if it is not in selected state- The painting in some other handlers either are repainted later automatically or require fully manual drawing which looks excessive for a simple task.
So I failed to find an easy way.
I added the additional conditions:
- The row must stay in selected state cause the tree could be in MultiSelected mode (
toMultiSelectis included). - The colors of selected and unselected states of the row may differ as well as different selected rows may have different colors too.
The best I could create is to write a handler on OnDrawTexr event:

This tree is produced by an array of records (oversimplified):
type
TJob=record
Running:Boolean;// the job is stopped or running
MaxDuration:integer;//0 - infinite, or seconds
Start:TDateTime;//The job start time
end;
- if the job is stopped its row should behave in the default treeview way.
- If the job is running and infinite it should be colored e.g. as green, if selected - as thick green
- If the job is running and have limited duration its row should have a transitioned color between green and red that changes constantly while meeting its deadline. If selected the color should be brighter.


Use
OnBeforeCellPaintfor non selected row, useColors.FocusedSelectionColorproperty for selected row..