OnCellColor not working with Advantage TAdsQuery

Hello

We are evaluating TDBAdvGrid as a replacement grid component for all grids in our Delphi 2007 application
Unfortunately, we've been unable to accomplish a simple and trivial task:
Highlighting specific rows in the grid based on a value of a specific field in the row.

The following code was used in the previous grid component and it worked perfect:

procedure TFormUserManager.tsDBGridUsersGetDrawInfo(Sender: TObject;
  DataCol: Integer; DataRow: Variant; var DrawInfo: TtsDrawInfo);
begin
  if AdsQueryUsers.FieldByName('loggedin').AsBoolean then
  begin
    DrawInfo.Font.Color := clGreen;
    DrawInfo.Font.Style := [fsBold];
  end;
end;


The TDBAdvGrid code below does not work.

procedure TFormUserManager.DBAdvGrid1GetCellColor(Sender: TObject; ARow,
  ACol: Integer; AState: TGridDrawState; ABrush: TBrush; AFont: TFont);
begin
  if AdsQueryUsers.FieldByName('loggedin').AsBoolean then
  begin
    AFont.Color := clGreen;
    AFont.Style := [fsBold];    
  end;
end;

The row font will change to Bold only when the row is selected, but adjacent rows are colored green... seemingly at random.

The TDBAdvGrid is set to a DataSource and its dataset is set to a TAdsQuery object.
We are using native Advantage client side drivers (9.10) to query advantage tables.
We are not using ADO.

We've attempted to change PageMode=false but nothing worked after that.

How can we color the rows based on the row values?

Please use grid.Cells[col,row] to check the value for. See demo ADOSelColor that shows exactly this functionality. If your DB field is not in the grid, add it as a hidden column in the grid.



procedure TFormUserManager.DBAdvGrid1GetCellColor(Sender: TObject; ARow,
  ACol: Integer; AState: TGridDrawState; ABrush: TBrush; AFont: TFont);
begin
  if DBAdvGrid.Cells[ConditionCol,ARow] = SomeValue then
  begin
    AFont.Color := clGreen;
    AFont.Style := [fsBold];    
  end;
end;

Bruno,
Thank you. This worked.

Regards,
Patrick