Results 1 to 2 of 2

Thread: Problem with NumericUpDown

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    74

    Problem with NumericUpDown

    I have a NumericUpDown with a min of 1 and a max of 100. What is happening, and I don't know why this is even able to happen, is that a user can clear the value and when the control loses focus, it is not redrawn or updated - it remains blanks. However, if a value is present and is greater than the max or less than the min, the control updates to either the max or min.

    But, even though the control shows no value, whatever last valid value was showing is actually still in memory and will be used as the NumericUpDown.Value.

    Why isn't the control updating upon losing focus if there isn't any value showing in the control?

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    74

    Re: Problem with NumericUpDown

    To reiterate, when the control loses focus, even if it is blank it is still holding the last value it had before it was cleared even though it it still shows itself as being blank.

    This is stupid but it works: If you change the value of the control upon losing focus, then it will display that new value. So if you capture the existing value into a variable, change the existing value for the control, then change it back to what is was via the variable you saved it's value into, it will display what it should be displaying in the first place.

    VB Code:
    1. Private Sub NumericUpDown_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles NumericUpDown.LostFocus
    2.         Dim i As Integer
    3.         i = NumericUpDown.Value
    4.         If NumericUpDown.Value < NumericUpDown.Maximum Then
    5.             NumericUpDown.Value = NumericUpDown.Value + 1
    6.         ElseIf NumericUpDown.Value = NumericUpDown.Maximum Then
    7.             NumericUpDown.Value = NumericUpDown.Value - 1
    8.         End If
    9.         NumericUpDown.Value = i
    10.     End Sub
    I still wouldn't call this issue resolved though; I cannot think of a single reason why the NumericUpDown should be able to stay blank if you have specified a minimum and maximum value.
    Last edited by AlphaScorpious; Apr 21st, 2006 at 11:33 AM. Reason: Code error

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width