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

Does NullValue have an internally set value?

1 Answer 58 Views
NumericUpDown
This is a migrated thread and some comments may be shown as answers.
Gleedo
Top achievements
Rank 1
Gleedo asked on 22 Sep 2011, 10:01 AM
We are using 2011 Q1.

I have a RadNumericUpDown setup as the following:

<telerik:RadNumericUpDown Margin="2" Name="GotoPageValue" IsInteger="True" Value="1" ValueChanged="GotoPageValue_ValueChanged" IsEnabled="False" IsEditable="True"></telerik:RadNumericUpDown>

NullValue is not set and when inspected under a debugger in the watch window, it looks like this:
NullValue=""

My problem is this.  When a user has navigated to a value like 2 using the up/down arrows, if they then highlight the value, delete it, and then hit the up arrow, the value always returns to 1.

The NullValue was previously set to 1 which I thought must be causing the problem, but after removing NullValue, the problem continued.

Basically inside the ValueChanged event and want to check if e.NewValue == null and if it is null, change e.NewValue to the previous value + 1.  Is this the wrong thing to do?

private void GotoPageValue_ValueChanged(object sender, RadRangeBaseValueChangedEventArgs e)
      {
         // has user cleared value manually?
         if (e.NewValue == null)
         {
            if (_pageNumber <= GotoPageValue.Maximum)
            {
               // reset back to previous value
               e.NewValue = _pageNumber;
            }
         }
 
         FireCommandActivated(SearchResultsNavigationToolbarCommand.GotoPageValue, e);
 
         // remember new value incase user clears value manually and hits up/down
         _pageNumber = (int)e.NewValue;
      }

1 Answer, 1 is accepted

Sort by
0
Gleedo
Top achievements
Rank 1
answered on 23 Sep 2011, 09:01 AM
Not to worry - I got around by using PreviewKeyDown and just checking if backspace or delete were being pressed.
Tags
NumericUpDown
Asked by
Gleedo
Top achievements
Rank 1
Answers by
Gleedo
Top achievements
Rank 1
Share this question
or