Delphi - cxGrid color display settings

1: When the value of a cell a condition is met, the entire row where the cell line color settings entire font set

Select cxGridDBTableView, click F11 to bring up the properties configuration panel, double-click, double-click editing OnCustomDrawCell in Events redraw event code.

code show as below:

IF  ' . 1 ' = AViewInfo.GridRecord.Values [cxgrdbclmnGridDBTableView5ysbj.Index] the then 
the begin 
   // entire row background color 
   // ACanvas.Canvas.Brush.Color: = clGreen; 
   // entire row font color set 
   // ACanvas.Font. Color: = clGreen; 
End ;

2: the value of the cell satisfies a certain condition, the cell background / font color setup

Add style preparation:

Drag a cxStyleRepository1 control, double-click the controls are added Styles and settings;

2: Select cxGridDBTableView, click F11 to bring up the properties configuration panel, double-click, double-click editing OnGetContentStyle in Events redraw event code.

code show as below:

 1 procedure TFrm_Qry_DBLT.cxGrid1DBTableView1StylesGetContentStyle(
 2   Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
 3   AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
 4 begin
 5     if ARecord is TcxGridDataRow  then
 6     //and not ARecord.Selected then //选中行导出没有颜色
 7     begin
 8         if ARecord.Values[cxGrid1DBTableView1.GetColumnByFieldName('CQ').Index] > 1 then
 9             AStyle := cxStyle1 //Belonging TcxStyleRepository 
10      End ;
 . 11  End ;

 

 

Note: Only cxStyleRepository1 set cxGrid style is applied, cxGrid lead only to Excel with color.

 

Guess you like

Origin www.cnblogs.com/jeremywucnblog/p/11423354.html