FMXGrid Row Size Questions

Hi,

I am creating a temp TTMSFMXGrid programatically and filling it with data so that I can then export it as a PDF but I am having problems with row sizing which I am failing to get to work automatically.

I am putting the contents of a memo into a cell and then calling AutoSizeRow but the row remains the default row height with the contents of the cell flowing below the row borders. I have also tried AutoSizeRows.

How can I do this please?

Regards,

Ken

Dear Ken, 


When are you calling AutoSizeRows? Please note that with FireMonkey styling, the elements that are necessary for autosizing are not yet loaded in the constructor of the form. If this is the case, then you will need to call AutoSizeRows in the OnApplyStyleLookup event.

Kind Regards, 
Pieter

Thanks Pieter,

I am doing the following:

  PDFGrid:=TTMSFMXGrid.Create(Self);
  PDFGrid.BeginUpdate;
  PDFGrid.ColumnCount:=1;
  PDFGrid.RowCount:=4;
  PDFGrid.ColumnWidths[0]:=580;
  PDFGrid.Clear;
  PDFGrid.FontNames[0,0]:='Helvetica';
  PDFGrid.Cells[0,0]:='Ingredients';
  PDFGrid.Colors[0,0]:=TAlphaColors.Lightgray;
  S:='';
  for I:=0 to ItemsListView.Items.Count-1 do
  begin
    S:=S+' whatever';
  end;
  PDFGrid.FontNames[0,1]:='Helvetica';
  PDFGrid.Cells[0,1]:=S;
  PDFGrid.FontNames[0,2]:='Helvetica';
  PDFGrid.Cells[0,2]:='Notes';
  PDFGrid.FontNames[0,3]:='Helvetica';
  PDFGrid.Cells[0,3]:='This is a long line of text';
  PDFGrid.AutoSizeRow(1);
  PDFGrid.AutoSizeRow(3);
  PDFGrid.EndUpdate;

Ken

Then you will need to use the OnApplystyleLookup event and call AutoSizeRow(1) and AutoSizeRow(3) there.


Kind Regards, 
Pieter

Pieter,

I have done the following:

  PDFGrid:=TTMSFMXGrid.Create(Self);
  PDFGrid.OnApplystyleLookup:=PDFGridApplyStyleLookup;

procedure TMainForm.PDFGridApplyStyleLookup(Sender: TObject);
begin
  TTMSFMXGrid(Sender).AutoSizeRow(1);
  TTMSFMXGrid(Sender).AutoSizeRow(3);
end;

But the above procedure is never being called.

Ken

Hi, 


You are not setting the parent, for the OnApplyStyleLookup event to be triggered, you need to set the parent.

Alternatively you could use the following code after the EndUpdate:

PDFGrid.EndUpdate;

PDFGrid.NeedStyleLookup;
PDFGrid.ApplyStyleLookup;
PDFGrid.AutoSizeRow(1);
PDFGrid.AutoSizeRow(3);

Kind Regards, 
Pieter

Thanks Pieter, both work fine.