FixedRows

I set FixedRows = 2 in preparation for putting the FilterEdit on the second FixedRow.


Just setting FixedRows to 2 causes several problems for me:

  1. I hide the last 2 columns in code with FGrid.HideColumn(FGrid.ColumnByHeader('<Header>')). After setting FixedRows to 2, only the last column is hidden -- the second to last column is now displayed.
  2. After displaying the grid and exiting the application, I get an EInvalidPointer exception, followed by an EAccessViolation.
If I change FixedRows to back to 1, both of the above problems disappear.

Am I misunderstanding the use of the FixedRows property?

I have retested this here with a default grid on the form and the code:


procedure TForm4.FormCreate(Sender: TObject);
begin
  advstringgrid1.FixedRows := 2;
  advstringgrid1.FilterEdit.Enabled := true;
  advstringgrid1.FilterEdit.Row := 1;
  advstringgrid1.SaveFixedCells := false;
  advstringgrid1.LoadFromCSV('c:\tmssoftware\cars.csv');
  advstringgrid1.Cells[1,0] := 'Brand';
  advstringgrid1.Cells[2,0] := 'Type';
  advstringgrid1.Cells[3,0] := 'CC';
  advstringgrid1.Cells[4,0] := 'Pk';
  advstringgrid1.Cells[5,0] := 'Cyl';
  advstringgrid1.Cells[6,0] := 'Kw';
  advstringgrid1.Cells[7,0] := 'Price';
  advstringgrid1.Cells[8,0] := 'Country';

  advstringgrid1.HideColumn(advstringgrid1.ColumnByHeader('Country'));
  advstringgrid1.HideColumn(advstringgrid1.ColumnByHeader('Price'));

end;

but I could not reproduce  this issue here. Correct columns are hidden, grid has no AV on exit.
What are you doing different?

I have also created a simple app and do not have any issues. I am guessing the issue is elsewhere in my code. I'll keep investigating!

I have found one of the problems -- our code is assuming that the field names are in row 0, which seems to be the case when FixedRows is set to 1. When I set FixedRows to 2, then the field names are in row 1 instead of row 0. Is there a property that controls which row the field names are populated to?


I have confirmed that the property Grid.Columns[3].Header is still referencing row 0, but the auto population of column headers with field names seems to have shifted to row 1 when I increment the FixedRows to 2.

It is currently by design that the DB fieldnames are shown in the last fixed row. We'll check the use of Grid.Columns[index].Header. We'll also check if we can add control for the row where the fieldname appears.