gridview float column

4 posts, 0 answers
  1. Mahsan
    Mahsan avatar
    9 posts
    Member since:
    Dec 2013

    Posted 22 Dec 2013 Link to this post

    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 
  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3989 posts

    Posted 24 Dec 2013 Link to this post

    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 >>
  3. Mahsan
    Mahsan avatar
    9 posts
    Member since:
    Dec 2013

    Posted 24 Dec 2013 Link to this post

    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



  4. Peter
    Admin
    Peter avatar
    1157 posts

    Posted 25 Dec 2013 Link to this post

    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 >>
Back to Top