Tech Tip: Customizing the style and color of rows in a selection based list box
PRODUCT: 4D | VERSION: 13.2 | PLATFORM: Mac & Win
Published On: January 15, 2013
To customize the style, font color, and background color of a row in a selection based list box use the Row Style, Row Font Color, and Row Background Color properties from the Property List as shown:
The Row Style, Row Font Color and Row Background Color properties can all be set to either an expression or a variable. The expression or variable will be evaluated for each row displayed.
For example, if the Row Background property is set to the expression "getBackgroundColor([People]dob)," the following method getBackgroundColor will be executed for each record displayed in the list box:
// ---------------------------------------------------- // Method: getBackgroundColor // Description // Returns the background that should be used based on the age // Parameters // $1 (Date) - Date of birth // ---------------------------------------------------- C_DATE($1;$dob) $dob:=$1 If (calculateAge ($dob)<21) $0:=0x00FF0000 //red Else $0:=0x00FFFFFF //white End if |
In this example, the [People]dob field is used to determine the background color of a list box row. If the person corresponding to the record being displayed is under 21 years of age, the background color will be red, otherwise the background color is white.