Page 1 of 1

Correct way to format a numeric value

Posted: Wed Dec 20, 2006 3:19 am
by IanMcCarthy
I have numerous numeric values, some with 1 and some with 2 decimal places (1.2 or 1.23).

I changed a textbox textformat option (in designer) from general to number and the numbers display with 2 decimal digits.

I can't change the number of decimal digits to 1 unless I untick the uselocalsetting option.

However if I do this then I lose the localisation selections for decimal and group separators.

Can I change the number of decimal places whilst still retaining localisation of decimal and group separators, etc.

What's the best way?

Many thanks

Ian

Correct way to format a numeric value

Posted: Wed Dec 20, 2006 3:54 am
by EDV Gradl
In this kind of case I use the various ToString methodes in the OnGetValue event

if (MyCondition == 1)
e.Value = MyNumber.ToString("#,#0.0");
else
e.Value = MyNumber.ToString("#,#0.00");

I hope that helps.

Correct way to format a numeric value

Posted: Wed Dec 20, 2006 4:00 am
by Vital
Select CustomFormat and type format string - #,#0.00
Thank you.