Format CustomFormat value in LiveBinding

5

I'm having trouble trying to use the CustomFormat property of LiveBinding , I'm trying to format a value obtained from the database into the number format with a thousand separator.

I'm using:

Format('%d',[Self.Owner.FieldByName('soma').Text])   

But the following error is returned:

  Invalid or incompatible with argument

    
asked by anonymous 19.02.2015 / 17:13

2 answers

2

Are you passing a String to be formatted to numeric is that right? It would not look like this:

Format('%d',[Self.Owner.FieldByName('soma').AsInteger])
    
19.02.2015 / 18:48
2

If you are passing a value with floating point , do not use the %d format, it is used for < in> integer , use %m for monetary values or %n for floating-point values. Your code looks like this:

Format('%n', [Self.Owner.FieldByName('soma').AsFloat]); 

Update

According to the Default LiveBindings Methods page function Format is a bit different when using LiveBindings , instead of specifying an array of arguments [.., ...] , is added as a parameter.

For example, the normal use of SysUtils.Format usually looks like this:

/ p>

Format('%d %d', [1, 2])

At LiveBindings you should use:

Format('%d %d', 1, 2)

Following this reasoning you can use:

Format('%n', Self.Owner.FieldByName('soma').AsFloat);  
    
23.02.2015 / 12:55