I'm working with dataset viewed on a TDBAdvGrid, and I'm using HTML Template in a column.
As follows:
<#MyField>
Here I define the Font color to clBlack. Appearently, when I define a "OnGetCellColor" eventhandler, it works with "ABrush.Color=clxxx" (say clYellow), but "AFont.Color=clxxx" doen't work. And I need to change the Font color when the cell is selected or not - and other properties of the cell. Any hint on how I can - in runtime - change the Font color depending on various properties of the cell?
br. Anders Balslev
With this information, I cannot reproduce the problem.
I started from the demo TDBAdvGrid CDSHTML and in the last column, I set the HTML template to: <#SIZE>
and added the OnGetCellColor event handler:
procedure TFormMain.GridAnimalsGetCellColor(Sender: TObject; ARow,
ACol: Integer; AState: TGridDrawState; ABrush: TBrush; AFont: TFont);
begin
if ACol = GridAnimals.ColCount - 1 then
AFont.Color:= clGreen;
end;
and this shows the text color in the last column as green.
Please compare with this demo what you are doing different.
Thank you so much. It also works on my sample program. However - the point is the the column 2 (which contains the HTML) - here the color is defined in the HTML statement, and this also works. But if the color defined in the HTML is depending on some properties, how can this be build in? Example: In the column "Size and weight", I would like to have the text "and weight is" to be clGreen if the weight is < 5 kg, and clRed if the weight is >= 5 kg
Can this be done?
Hi again Bruno
I think I found out:
It works on the entire text content, not part of the text.
Avoid specifying color in HTML template, then AFont.Color works in "GetCellColor"
the case can be closed
br.
Anders
Yes, I can confirm your findings are correct.