This is a migrated thread and some comments may be shown as answers.

GridViewDecimalColumn defaulting to 4 decimal places even though it is assigned to only 2

3 Answers 186 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dave
Top achievements
Rank 1
Dave asked on 01 Dec 2011, 10:30 PM
Hey guys,

Just like the title says. I am setting the DecimalPlaces property on a GridViewDecimalColumn to a value of 2, both in the designer and in my code. When the grid displays, however, four decimal places show. Why is the GridViewDecimalColumn's DecimalPlaces property not using the value I assigned to it? 

Code: 

((Telerik.WinControls.UI.GridViewDecimalColumn)rgvGrid.Columns["Amount"]).DecimalPlaces = 2;

3 Answers, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 05 Dec 2011, 02:41 PM
Hello Dave,

Thank you for your question.

The GridViewDecimalColumn's DecimalPlaces property defines the column editor's number of decimal places. To format the value of the column, you should use its FormatString property:
column.FormatString = "{0:N2}";

I hope it helps.

Best regards,
Alexander
the Telerik team

Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.

0
Yaroslav
Top achievements
Rank 1
answered on 18 May 2012, 08:47 AM
I was having exactly same problem. The {0:N2} did not worked. What did worked for me was {0:f}
0
Stefan
Telerik team
answered on 23 May 2012, 06:26 AM
Hello Yaroslav,

Thank you for writing.

I have tested the "N2" format and it works correctly on my end. If you continues experiencing this issue, please open a new support ticket and attach a sample project which replicates the it. We will investigate it and provide you with further support.

Kind regards,
Stefan
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
GridView
Asked by
Dave
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Yaroslav
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or