Filter and virtual data not working


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

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

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;