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

Initial Value different than 0

2 Answers 72 Views
NumericUpDown
This is a migrated thread and some comments may be shown as answers.
Daní
Top achievements
Rank 1
Daní asked on 22 Feb 2017, 11:04 AM

Hi,

I have a NumericUpDown control wich value is bound to a viewmodel's property that initially is null. I'd like to set an initial value so when user first click on one of the arrows the control starts at this value instead of starting at Minimum + SmallChange (1 by default).

 

Is this possible

 

Thanks in advance

2 Answers, 1 is accepted

Sort by
0
Kalin
Telerik team
answered on 27 Feb 2017, 08:25 AM
Hi DanĂ­,

This can be done by inheriting the NumericUpDown control and overriding the ChangeValue method. You could implement the following logic - when the current Value is still null, you could change the delta to the desired default value and the base call will do the job:

public class CustomNumericUpDown : RadNumericUpDown
{
    protected override void ChangeValue(double delta)
    {
        if (!this.Value.HasValue)
        {
            delta += 10d;
        }
 
        base.ChangeValue(delta);
    }
}

Hope this helps.

Regards,
Kalin
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Daní
Top achievements
Rank 1
answered on 01 Mar 2017, 01:51 PM
Thanks Kalin, it works like a charm
Tags
NumericUpDown
Asked by
Daní
Top achievements
Rank 1
Answers by
Kalin
Telerik team
Daní
Top achievements
Rank 1
Share this question
or