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,
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.
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,
Thanks Pieter, both work fine.