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

gridview float column

3 Answers 365 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mahsan
Top achievements
Rank 1
Mahsan asked on 22 Dec 2013, 07:38 AM
Hello Telerik Team
I want to have a column in radgrid which type is float or decimal ,but I dont want to have a fix decimal point .for example I want to enter number 2.35 or 123,4.6589 so I use the code bellow 

 GridViewDecimalColumn DecimalColumn = new GridViewDecimalColumn();
            DecimalColumn .Width = 150;
            DecimalColumn .Name = "Decimal";
            DecimalColumn .HeaderText = "Decimal";
            DecimalColumn .ThousandsSeparator = true;
            radGridView1.Columns.Add(DecimalColumn);
but there is a problem with thousandsSeparator .when I am typying number in the cell and when I leave the cell there is no thousandsSeparator 
please help me.
 

thank you 

3 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 24 Dec 2013, 07:14 AM
Hello Mahsan,

Thank you for contacting Telerik Support.

GridViewDecimalColumn.ThousandsSeparator property is used for GridSpinEditor initializing. If your requirement is to display the decimal value with thousands separator when the cell is not in edit mode as well, you may use the following approach:
GridViewDecimalColumn decimalColumn = new GridViewDecimalColumn("Decimal");
decimalColumn.FormatString = "{0:#,##0.00}";
decimalColumn.ThousandsSeparator = true;
decimalColumn.DataType= typeof(decimal);
radGridView1.Columns.Add(decimalColumn);

I hope this information helps. Should you have further questions, I would be glad to help.

Regards,
Desislava
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Mahsan
Top achievements
Rank 1
answered on 24 Dec 2013, 08:20 AM
Thank you Desislava for your reply,but I have 2 problem:
1.Decimal point :I dont Want To have fix decimal point  , for example I want to write 12.36 or 12.3658 or 12 or 12.47859
2.ThousandsSeparator :I want to have ThousandsSeparator when I edit The Cell And When I Leave The Cell

If I use GridViewMaskBoxColumn 
 GridViewMaskBoxColumn dec1 = new GridViewMaskBoxColumn();
                            dec1.Name = "mask1";
                            dec1.HeaderText = "mask1";
                            dec1.Width = 120;
                            dec1.Mask ="N2";
                            dec1.DataType = typeof(float);
                            radGridView1.Columns.Add(dec1);
                            radGridView1.Columns["mask1"].FormatString = "{0:N2}";
there is no problem with ThousandsSeparator  but I have fix decimal point
if I Use GridViewDecimalColumn 
GridViewDecimalColumn decimalColumn = new GridViewDecimalColumn("Decimal");
            decimalColumn.Name = "decimal";
            decimalColumn.HeaderText = "decimal";
            decimalColumn.Width = 120;
            decimalColumn.ThousandsSeparator = true;
            decimalColumn.DataType = typeof(decimal);
            radGridView1.Columns.Add(decimalColumn);
there is no problem with decimal point but I ahve problem with ThousandsSeparator  

please help me to solve this problem



0
Peter
Telerik team
answered on 25 Dec 2013, 03:07 PM
Hello Mahsan,

Thank you for writing back and for the provided additional details.

I would like to clarify that this scenario is not supported and this is a restriction of the String.Format method and the Decimal.ToString method and our RadMaskedEditBox and RadSpinEditor (and also the standard .NET controls) do not offer such functionality because String.Format must have a decimal point which is fixed and valid since the float types have restrictions for the numbers after the decimal point. Even the decimal type has a limit to its precision (28-29 significant digits).

I hope that you find this information useful.  

Regards,
Peter
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
Mahsan
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Mahsan
Top achievements
Rank 1
Peter
Telerik team
Share this question
or