Initial Value different than 0

3 posts, 0 answers
  1. Daní
    Daní avatar
    314 posts
    Member since:
    Feb 2008

    Posted 22 Feb 2017 Link to this post

    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. Kalin
    Admin
    Kalin avatar
    1352 posts

    Posted 27 Feb 2017 Link to this post

    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.
  3. Daní
    Daní avatar
    314 posts
    Member since:
    Feb 2008

    Posted 01 Mar 2017 Link to this post

    Thanks Kalin, it works like a charm
Back to Top