TAdvStringGrid: Fixed row count must be less than

Hi,


I have a TAdvStringGrid which needs to be empty at the first use, but I want it to have 2 fixed rows right from the start: One with column headers and one underneath for FilterEdit controls. It looks like this is not easily possible, because whenever I configure only two rows and want to set two fixed ones, I get the following error:



---------------------------
Debugger Exception Notification
---------------------------
Project RecipientSearchTests.exe raised exception class EInvalidGridOperation with message 'Fixed row count must be less than row count'.
---------------------------
Break   Continue   Help   
---------------------------


If I set three rows total and configure 2 to be fixed I don't get this message, but have an empty row of course which I don't need/want. My use case is starting with an empty grid and dragging rows from another grid into the empty one or back again, until it is empty again.

So, how do I start with an empty grid only containing two fixed rows?

Thanks!
You need to set FixedRowAlways = true, example:

  AdvStringGrid1.RowCount:= 2;
  AdvStringGrid1.FixedRows:=2;
  AdvStringGrid1.FixedRowAlways:=true;

Thanks, that works now, but what is FixedRowAlways doing? I can't find it in the PDF docs and see a strange behavior: In the designer, enabling FixedRowAlways and setting Rowcount to 2 automatically sets FixedRows to 1 and I'm unable to rise it. If I set RowCount to e.g. 7 to provide some example data in the designer, FixedRows is set 2 again.


But for my initial empty grid I still need to say RowCount 3, to get FixedRows 2 and in the code I reset RowCount to 2 and can keep my FoxedRows of 2.

So the former described exception is really gone now, but I don't understand the behavior in the designer. Any explanation? Thanks!

This is related to a shortcoming in the base class TStringGrid where the requirement is that RowCount > FixedRows. We worked-around this shortcoming with the FixedRowsAlways property that internally "remembers" the FixedRows event when FixedRows = RowCount.