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

FormatString doesn't work

1 Answer 100 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ales
Top achievements
Rank 1
Ales asked on 14 Mar 2012, 05:35 PM
Hi All,

a have this procedure :

foreach (GridViewDataColumn dataColumn in radGridBatches.Columns)
 {               
      dataColumn.TextAlignment = ContentAlignment.BottomRight;
      dataColumn.FormatString = "{0:F2}";
}





but the number in Grid are 600
                                           592.35
                                          600
                                           etc...
need somebody help ?

lot thanks Alda

PROBLEM SOLVED, DOUBLE CONVERTED TO DECIMAL

1 Answer, 1 is accepted

Sort by
0
Ivan Petrov
Telerik team
answered on 16 Mar 2012, 05:00 PM
Hello Alda,

Thank you for writing.

In order to make this format string to work, you have to apply it to a GridViewDecimalColumn. If you are setting it to a GridViewTextBoxColumn, it will not work. If this is not your case, I would kindly ask you to provide some more details on your case and grid setup. 

I am looking forward to you reply.

Kind regards,
Ivan Petrov
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Ryan
Top achievements
Rank 1
commented on 12 Jan 2022, 11:10 PM

Then why have a FormatString property for GridViewTextBoxColumn if it isn't useable?
Dess | Tech Support Engineer, Principal
Telerik team
commented on 13 Jan 2022, 08:35 AM

Hello, Ryan,

The FormatString property is inherited by the basic class GridViewDataColumn that is common for all column types. But this property is not respected by all column types, e.g. GridViewTextBoxColumn. Numerical data is usually appropriate to be handled by a GridViewDecimalColumn or a GridViewMaskBoxColumn  with the appropriate numeric mask.

I hope this information helps.
Tags
GridView
Asked by
Ales
Top achievements
Rank 1
Answers by
Ivan Petrov
Telerik team
Share this question
or