Topic: Formatting a calculated field

Can I format a calculated field. It must be Currency with two decimals

Re: Formatting a calculated field

Yes, you can using script, example for first column:


procedure Form1_TableGrid1_OnChange (Sender: TObject);
begin
   if Form1.TableGrid1.Columns[0] is TNxNumberColumn then
    begin
        TNxNumberColumn(Form1.TableGrid1.Columns[0]).FormatMask := '#,##0.00';
        TNxNumberColumn(Form1.TableGrid1.Columns[0]).Footer.FormatMask := '#,##0.00';
    end;
end;
Dmitry.

Re: Formatting a calculated field

It seems not to work for me. Can you please help me?

Post's attachments

Attachment icon Upload.zip 334.26 kb, 370 downloads since 2018-06-22 

4 (edited by derek 2018-06-22 11:04:49)

Re: Formatting a calculated field

Hi Kees,
Attached is the way that I've always formatted columns (and footers and headers).  I'm sure it's not the only way but it's always worked for me (so it's what I stick with!).
A couple of things to mention;
1.  in the tablegrid,  columns start at 0 rather than 1 so vergoeding is actually column3 in your example.
2.  you hadn't actually associated the tablegrid1 'onchange' event with the code in the script.
And apologies but I don't have a 'euro' symbol on my keyboard so you'll have to make do with £ - LOL! (just replace £ in the tablegrid properties( footer settings) and in the script).
Anything not clear, then just drop a message.
Regards,
Derek.

Post's attachments

Attachment icon kees format.zip 337.35 kb, 435 downloads since 2018-06-22 

Re: Formatting a calculated field

kees.krause wrote:

It seems not to work for me. Can you please help me?

Check it out

Post's attachments

Attachment icon Upload_fixed.zip 4.58 kb, 434 downloads since 2018-06-22 

Dmitry.