Does NullValue have an internally set value?

2 posts, 0 answers
  1. Gleedo
    Gleedo avatar
    2 posts
    Member since:
    Sep 2004

    Posted 22 Sep 2011 Link to this post

    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;
          }
  2. Gleedo
    Gleedo avatar
    2 posts
    Member since:
    Sep 2004

    Posted 23 Sep 2011 Link to this post

    Not to worry - I got around by using PreviewKeyDown and just checking if backspace or delete were being pressed.
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top