How to set the Row Text color in a TwwDBGrid?
Hi Team,
D10.3.3, latest IP VCL.
I want to set the Row Text color of a TwwDBGrid based on the value of a field in the row.
e.g. If a DateTime field in the row is > 3 days old, paint the Text clRed, otherwise normal.
If it makes any difference, I am using Delphi Styles.
Regards & TIA,
Ian
-
Official comment
You can use the OnCalcCellColors for this. The following example puts the row in red if Customer No is more than 800
procedure TBtnGridForm.wwDBGrid1CalcCellColors(Sender: TObject;
Field: TField; State: TGridDrawState; Highlight: Boolean;
AFont: TFont; ABrush: TBrush);
begin
if TwwDBGrid(Sender).DataSource.DataSet.fieldbyname('Customer No').AsInteger>800 then
ABrush.Color:= clRed;
end;Comment actions
Please sign in to leave a comment.
Comments
1 comment