Hello! Is there a way to set a row's color according to a field value from a dataset hooked to DbAdvGrid?
Use OnGetCellColor event, and check the condition(s) using the corresponding column(s).
procedure TMyForm.MyDBAdvGridGetCellColor(Sender: TObject; ARow,
ACol: Integer; AState: TGridDrawState; ABrush: TBrush; AFont: TFont);
var
LCol : integer;
begin
if (ARow >= MyDBAdvGrid.FixedRows) and (ACol >= MyDBAdvGrid.FixedCols) then begin
try
LCol := MyDBAdvGrid.ColumnByFieldName['CityName'].Index;
except
LCol := -1;
end;
if LCol > 0 then
if MyDBAdvGrid.Cells[LCol, ARow].ToLower.Trim = 'new york' then begin
AFont.Color := clNavy;
ABrush.Color := clYellow;
end;
end;
end;
The demo under Demo\DBAdvGrid\ADOSelColor also demonstrates this