Tech Tip: Coloring rows in an entity listbox
PRODUCT: 4D | VERSION: 20 | PLATFORM: Mac & Win
Published On: July 22, 2024
Entity listboxes can easily have their row colors changed based on the values in a column.
In this example, within the listbox's properties, teh Background color expression and font color expression are set to the names of the project methods setColor and setTextColor respectively that have been created.
Within setColor, the method checks the values in each of a specific column to determine which color should be set. In this case, the value is "Magnitude".
#DECLARE()->$color : Integer Case of : (This.Magnitude>=9) //9.0 and above $color:=0x00FFFFFF : (This.Magnitude>=7) //7.0 and above $color:=0x00FFFFFF : (This.Magnitude<7) //less than 7 $color:=0x0000 End case |
The setTextColor method is very similar
#DECLARE()->$color : Integer Case of : (This.Magnitude>=9) //9.0 and above $color:=0x00FF0000 : (This.Magnitude>=7) //7.0 and above $color:=0x00FF8C00 : (This.Magnitude<7) //less than 7.0 $color:=0x00FFFA5C End case |
The resulting listbox appears like this.
![](https://kb.4d.com:443/kbase/assets/images/79476-2.jpg)