When I set the grid property ShowBooleanFields to True, I can see a nice checkbox in the grid which is great!
But I also want to change the color of a row depending if my Boolean field is True or False.
With ShowBooleanFields=False is use following code:
procedure TfrmMyForm.DBAdvGrid1GetCellColor(Sender: TObject; ARow,
ACol: Integer; AState: TGridDrawState; ABrush: TBrush; AFont: TFont);
begin
if DBAdvGrid1.Cells[DBAdvGrid1.ColumnByFieldName['Actief'].Index,ARow]='False' then
AFont.Color := clRed
else
AFont.Color := clBlue;
end;
When ShowBooleanFields=True, this doesn't work any more.
I hoped to be able to use a property DBAdvGrid1.Booleans[Acol,ARow] as you have DBAdvGrid1.Floats or DBAdvGrid1.Dates but this doesn't exist and the value of DBAdvGrid1.Cells[ACol,ARow] is empty.
How should I read the value of this Boolean field?
In the TDBAdvGrid samples, there is a demo ADOSelection that might help. This shows selection via checkboxes.
Thanks for the tip.
The examples are indeed a great resource and I found how to do it.