change property

Please,

how to change displayformat property of memo field at runtime, to number %2.2n

Thanks

Comments

  • PolomintPolomint Australia

    G'day

    If you are looking to do this in Delphi code it is quite easy.

    Firstly you need to have connected the Memo to a Delphi variable. Then you can just set the Property of the Variable to the chosen Format. The best place to do all this is in the BeginReport Event.

    Cheers, Paul

  • PolomintPolomint Australia
    edited May 25

    G'day again Felipe,

    Looking again at your original post, I realised your question might be more about translating '%2.2n' (used in a Delphi Format Function call) to the Property value for FastReport. And my previous answer was too short (wrote it on my phone on the tram)!

    So in your equivalent of the OnBeginDoc Event for your <<Report Object>> you need to:

    • declare a variable (either local to the Event Method or globally in the Unit if you need to refer to it elsewhere) e.g. "FieldOnReport : TfrxMemoView;"
    • link to the variable e.g. "FieldOnReport := <<Report Object>>.FindObject (<<name as a string>>) as TfrxMemoView;"
    • set the Memo up as Numeric e.g. "FieldOnReport.DisplayFormat.Kind := fkNumeric;"
    • set the Memo's Format String e.g. "FieldOnReport.DisplayFormat.FormatStr := '00';"

    Note the last step translated your '%2.2n' into '00'!

    There are other ways to do this in Delphi code (e.g. set "FieldOnReport.Text = Format ('%2.2n', [<<data value>>]);" in the BeforePrint Event for the Band containing your Memo) but if the Format is static for the report then OnBeginDoc Event is the best option.

    Cheers, Paul

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.