When you specify a cell that requires a style (such as a font color set to red and a background color set to yellow), you can do this as follows:
1. Add the Csstylerepository control and create a new Style, set the foreground (textcolor), background color (color).
2. Write the Styles.ongetcontentstyle event for the Table component in Cxgrid:
procedureTaccumulationfundform.gridaccumulationfundstylesgetcontentstyle (Sender:tcxcustomgridtableview; Arecord:tcxcustomgridrecord; Aitem:tcxcustomgridtableitem; varastyle:tcxstyle);begin ifAitem.index =Gridaccumulationfundperson_name. Index Then begin ifarecord.values[Gridaccumulationfundhas_employee. Index] ='N' Then beginAstyle:= dmresource.style_idcardnotexists; End; End;End;
Attention:
The above code means: If AItem is the cell in which you want to set the style, the specified field value in the Arecord data is found to match the criteria, and if successful, the Astyle is set to the specified Style object. In this way, the effect is achieved.
Customizing cell styles for Cxgrid based on criteria