Disable auto round for decimal

8 posts, 1 answers
  1. Flavio
    Flavio avatar
    22 posts
    Member since:
    Jan 2011

    Posted 27 Mar 2012 Link to this post

    Hi,

      I updated my applications to new version, Telerik 2012 Q1 but before I was using Telerik 2012. When I was testing the application I saw a grid doesn't display the value of the previous version of Telerik. When I set a value 12.379 the value is rounded to 12.38 and in the previous version I set a value 12.379 and it keeps the value.
     I'd like know how to do disable the round option when I set values like 12.379?

    Example attached.

    Thanks!
  2. Answer
    Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 30 Mar 2012 Link to this post

    Hello Flavio,

    Thank you for writing.

    GridViewDecimalColumn has a property called DecimalPlaces which determines how many decimals should be displayed when the cell is edited. Additionally, there is a FormatString property of the column, which is used to format the cells when they are not in edit mode:
    ((GridViewDecimalColumn)radGridView1.Columns["MyColumnName"]).DecimalPlaces = 5;
    ((GridViewDecimalColumn)radGridView1.Columns["MyColumnName"]).FormatString = "{0:#,0.0000}";

    I hope this helps.

    Regards,
    Stefan
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Alejandro
    Alejandro avatar
    2 posts
    Member since:
    Oct 2012

    Posted 01 Oct 2012 Link to this post

    it does not work ... any idea?? is still auto rounding
  5. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 04 Oct 2012 Link to this post

    Hi Alejandro,

    Thank you for writing.

    You need to set the DecimalPlaces and the FormatString of the column with the number of decimal places desired. For example in my previous post I am allowing up to 5 decimal places, so any extra one will be rounded.

    I hope this helps.
     
    Kind regards,
    Stefan
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
  6. Aaron
    Aaron avatar
    9 posts
    Member since:
    Jun 2009

    Posted 20 Jun 2013 Link to this post

    The solution you are proposing is not flawless, because if you put a number like 28.9999999999999 will get round to 29, so it is not good if your data needs to be accurate and without rounding.
  7. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 25 Jun 2013 Link to this post

    Hi Aaron,

    Depending on your requirements, you can set the corresponding DecimalPlaces and FormatString. If you do not want rounding just set it the desired DecimalPlaces and FormatString:
    ((GridViewDecimalColumn)radGridView1.Columns["DecimalColumn"]).DecimalPlaces = 5;
    ((GridViewDecimalColumn)radGridView1.Columns["DecimalColumn"]).FormatString = "{0:N5}";

    Make sure you column DataType supports decimals as well i.e. decimal, double.

    Regards,
    Stefan
    Telerik
    RadChart for WinForms is obsolete. Now what?
  8. Saif
    Saif  avatar
    30 posts
    Member since:
    Apr 2014

    Posted 13 Jan in reply to Aaron Link to this post

    I'm having the same problem, even if i apply the decimalplaces and formatstring the value that i entered is still rounding
  9. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 15 Jan Link to this post

    Hello Saif,

    Can you please provide an example - what value are you entering, and also what column type you use and the settings in the DecimalPlaces and the FormatString properties?

    Regards,
    Stefan
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for WinForms is Visual Studio 2017 Ready