devexpress vgridcontrol displayformatstring don't work

290 Views Asked by At

I have an unbound vgrid control. One field's unbound expression is like this:

Iif([NETSAL]=0, 0, [GP] / [NETSAL] * 100 )

The unbound type is decimal, the format type is numeric, the format string n1.

The problem is, that I don't get the right formatted values. F. e. if gp=200 and netsal=1500, I should get: 13,3, but I get 0,0. I checked the computed value, this is 0,0 too.

But if gp=2500 ant netsal=1000, then the value is 200, so it seems, that the value is rounded.

But why?

Thanks.

1

There are 1 best solutions below

0
On BEST ANSWER

The expression result type depends on expression members types. In your case, all members of the expression [GP] / [NETSAL] are integer values. This is why the result is rounded to the nearest integer value.

Adding a decimal constant value to the expression will change the type of the expression result to decimal. According to the Criteria Language Syntax, the type of a numeric constant can be declared using special literals. For the decimal type, the literal is 'm'.

Try the following expression, it should work as you expect:

Iif([NETSAL]=0, 0, 1m * [GP] / [NETSAL] * 100 )