Page 1 of 1
Format Decimal Point
Posted: Mon Apr 06, 2009 3:10 am
by Siang Hwee
Hi,
I want to format the decimal value to 2 decimal point such as 1,234.56 thru the StiText component in C#. I found there is a property call TextFormat and a method call Format. But i just have no idea how to format the data. Please assist.
Thanks and Regards,
Goh
Format Decimal Point
Posted: Mon Apr 06, 2009 3:50 am
by Brendan
Hi,
Yes, you can use the TextFormat Property. You can right click on the text component and choose 'Text Format' from the context menu or press the elipsis button from the properties window.
This will bring up the Text Formatting window and from here you can choose 'Number' from the listing on the left. I think the default options maybe be all you need but these might initally come from your regional settings.
Format Decimal Point
Posted: Mon Apr 06, 2009 4:09 am
by Siang Hwee
Brendan,
Thanks for your reply. What i need is actually format from programming side. inside the C# code i found the StiText object has the property TextFormat but i just don't know how to format thru this property, besides, there is another property StringFormat but not clear how to use it. Please assist.
Thanks and Regards,
Goh
Brendan wrote:Hi,
Yes, you can use the TextFormat Property. You can right click on the text component and choose 'Text Format' from the context menu or press the elipsis button from the properties window.
This will bring up the Text Formatting window and from here you can choose 'Number' from the listing on the left. I think the default options maybe be all you need but these might initally come from your regional settings.
Format Decimal Point
Posted: Mon Apr 06, 2009 9:46 am
by Brendan
Hi,
When setting the TextFormat property through code for an StiText entity you can use the StiNumberFormatService class.
Code: Select all
txtName.TextFormat = new Stimulsoft.Report.Components.TextFormats.StiNumberFormatService(1, ".", 2, ",", 3, true, true, " ");
where txtName is an StiText instance.
The StiNumberFormatService has an overloaded constructor for different options.
Format Decimal Point
Posted: Mon Apr 06, 2009 6:11 pm
by Siang Hwee
Thanks for your help. My problem solved.