Filter and virtual data not working

Hi,

Using TAdvStringGrid.  I've added event OnGetDisplText like this:


procedure TForm2.ConfigGridGetDisplText(Sender: TObject; ACol, ARow: Integer; var Value: string);
const
  ynStr : array[Boolean] of String = ('No', 'Yes');
begin
  if ARow > 0 then  
    case ACol of
      1 : Value := MyList[ARow - 1].Name;
      2 : Value := ynStr[MyList[ARow - 1].Running];
    end;
end;



And then I've added a filter where


Column := 2;
Condition := 'Yes';
Data := fcVirtual;
Method := fmLiteral;



When FilterActive := True, the Grid.RowCount is reduced to only the number of items in MyList where the Running property = True, but the items displayed in the grid are still incremental.

eg.  If I have 3 items in my list, and

  • item[0].Running = True
  • item[1].Running = False
  • item[2].Running = True
then the grid only shows 2 rows (correct), but shows item[0] and item[1], not item[0] and item[2] as it should.

What am I doing wrong?

Thanks for your help.

Yes, indexes for the OnGetDisplText are incremental and are as such the display indexes. You can always convert the display indexes to real indexes with

grid.RealRowIndex(DisplIndex): integer;