StringGrid AddButton OnGetCellColor

Windows 7 SP1 x64
RAD Studio 10.1 Berlin Update 2
TMS VCL UI Pack v10.1.7.0


I have recently found a behaviour that has been missing for some times.

Back in the days, setting the AFont.Color in the OnGetCellColor of a grid for cell using an AddButton would change the color of the text to that button.

Between TMS Component Pack v9.0.2.0 and v9.0.4.0 (I could not test between these version), the behaviour has been lost and the text stays the same colour.

Is this behaviour fixable on your side or do I have to adapt my code?

Here's my test case:
  • Create a new project
  • Add an AdvStringGrid
  • Add and connect these event:
procedure TForm1.FormCreate(Sender: TObject);
  AdvStringGrid1.AddButton(1,1,20,20,'01', haCenter, vaCenter);
  AdvStringGrid1.AddButton(2,1,20,20,'02', haCenter, vaCenter);
  AdvStringGrid1.AddButton(3,1,20,20,'03', haCenter, vaCenter);

procedure TForm1.AdvStringGrid1GetCellColor(Sender: TObject; ARow, ACol: Integer; AState: TGridDrawState; ABrush: TBrush; AFont: TFont);
  if (ACol mod 2) = 0 then
    AFont.Color := clRed;
    AFont.Style := [fsBold];
  • Build and Run the project.

Expected behaviour:
Button "02" has a bold and red text.

Actual behaviour:
Button "02" has a bold text, but the text colour did not change.

An issue slipped in for font color for buttons in the grid in v10.1.7
We already fixed this internally and the next update will address this.

Just to be sure that I have been understood.

This behaviour dates way back from v10.1.7.0
It affects the OnGetCellColor since a least the v9.0.4.0

We see this was due to changes related to VCL styles support.
When no VCL styles are used, we have restored the behavior that it will use the customized color via OnGetCellColor. This fix will be in the next update.