Hi,
You can accomplish this by setting the ActiveRecord within the buffer to the current row. The code below demonstrates this.
type
TTMSFNCGridDatabaseAdapterOpen = class(TTMSFNCGridDatabaseAdapter);
procedure TForm1.TMSFNCGrid1GetCellLayout(Sender: TObject; ACol,
ARow: Integer; ALayout: TTMSFNCGridCellLayout;
ACellState: TTMSFNCGridCellState);
var
c: Integer;
f: TField;
o: Integer;
s: string;
procedure SetActiveRecord;
var
ro, tp, off, rs: Integer;
begin
ro := TTMSFNCGridDatabaseAdapterOpen(TMSFNCGridDatabaseAdapter1).GetRecordNo;
tp := TMSFNCGridDatabaseAdapter1.DataLink.ActiveRecord + TMSFNCGrid1.TopRow - TMSFNCGrid1.FixedRows;
off := tp - (ro - 1);
rs := ARow - TMSFNCGrid1.TopRow + off;
TMSFNCGridDatabaseAdapter1.DataLink.ActiveRecord := rs
end;
begin
if not TMSFNCGridDatabaseAdapter1.CheckDataSet then
Exit;
c := ACol - TMSFNCGrid1.FixedColumns;
if TMSFNCGridDatabaseAdapter1.Active and (ARow >= TMSFNCGrid1.FixedRows) and (c >= 0) and (c <= TMSFNCGridDatabaseAdapter1.Columns.Count - 1) then
begin
f := TMSFNCGridDatabaseAdapter1.FieldAtColumn[c];
if Assigned(f) then
begin
o := TMSFNCGridDatabaseAdapter1.DataLink.ActiveRecord;
try
SetActiveRecord;
s := f.AsString;
if s.StartsWith('BM') then
ALayout.Fill.Color := gcRed;
finally
TMSFNCGridDatabaseAdapter1.DataLink.ActiveRecord := o;
end;
end;
end;
end;