Dynamic formatting

edited 4:11AM in FastReport 3.0
FR309/D5ENT

I need assign the display format to cells on DBCross in run-time.

I'm using the event OnPrintCell for change the property DisplayFormat, but not result.
procedure Page1OnBeforePrint(Sender: TfrxComponent);
begin
  FmtMoney := '%2.2m';
  FmtDecimal := '%g';
end;

procedure DBCross1OnPrintCell(Memo: TfrxMemoView; RowIndex, ColumnIndex, CellIndex: Integer; RowValues, ColumnValues, Value: Variant);
begin
  if DBCross1.IsGrandTotalRow(RowIndex) then
  begin
    case CellIndex of
      0: Memo.DisplayFormat.FormatStr := FmtMoney;
      1: Memo.DisplayFormat.FormatStr := FmtDecimal;
    end;
  end;
end;

Sorry, for my english

Regards

Comments

  • edited 4:11AM
    You can't change the format in this event. Use the following code instead:

    Memo.Text := Format('%2.2m', [Value]);

    Note that you should check for Null values. Also in the OnCalcWidth event you should calculate the new width (to increase width of cells).

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.