Variable NumberDecimalDigits

3 posts, 1 answers
  1. Geoff Smith
    Geoff Smith avatar
    48 posts
    Member since:
    Mar 2010

    Posted 29 Sep 2010 Link to this post

    Hi,

    Is it possible to allow more decimal digits if the user enters more. Say I have NumberDecimalDigits=2 and the user types in 10.123, then the control will show 10.12. I would like it to show 10.123. But if the user types in 10, I would like to show 10.00 (so I can't just change NumberDecimalDigits to 3).

    Any suggestions?

    Thanks!
  2. Answer
    George
    Admin
    George avatar
    1332 posts

    Posted 04 Oct 2010 Link to this post

    Hello Geoff,

    Unfortunately this scenario if not supported out of the box. However, I would suggest you to implement the logic by yourself. Here are the steps to accomplish this:

    1. Handle ValueChanged event.
    2. In the handler add your custom logic to change the NumberDecimalDigits property. I would suggest you to use e.NewValue to get the inputted value in the RadNumericUpDown control. For example:
    if (e.NewValue.HasValue)
                {
                    if ((e.NewValue * 1000) % 10 != 0 )
                    {
                        numericControl.NumberDecimalDigits = 3;
                    }
                    else
                    {
                        numericControl.NumberDecimalDigits = 2;
                    }
                }

    Attached you can find the sample. I hope this suits your needs.


    Greetings,
    George
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Geoff Smith
    Geoff Smith avatar
    48 posts
    Member since:
    Mar 2010

    Posted 04 Oct 2010 Link to this post

    Ah, cool. Thanks for the tip!
Back to Top