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

Variable NumberDecimalDigits

2 Answers 96 Views
NumericUpDown
This is a migrated thread and some comments may be shown as answers.
Geoff Smith
Top achievements
Rank 1
Geoff Smith asked on 29 Sep 2010, 09:25 AM
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 Answers, 1 is accepted

Sort by
0
Accepted
George
Telerik team
answered on 04 Oct 2010, 12:57 PM
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
0
Geoff Smith
Top achievements
Rank 1
answered on 04 Oct 2010, 03:16 PM
Ah, cool. Thanks for the tip!
Tags
NumericUpDown
Asked by
Geoff Smith
Top achievements
Rank 1
Answers by
George
Telerik team
Geoff Smith
Top achievements
Rank 1
Share this question
or